order of matrix multiplication- DP