Approach 2 of sum of submatrices

this code is not giving the correct answer
for input
2
1 1
1 1
it is showing output
130316
but the ans should be 16
please somebody help me