dp m*n solution