Pranjal Bhaiya gave up his materialistic life as a developer, and chose to become a farmer in MATRIXLand. He was enjoying his life plowing fields, predicting the right time for sowing seeds.
On one fine day, as usual, Dumit Drivastav, a native of MATRIXLand had a problem. He couldn't bear how happy Pranjal Bhaiya was so he used his sources and managed to destroy the canal flowing near Pranjal's field, thus destroying the source of water.
Pranjal Bhaiya was very annoyed so he thought of answering Dumit in his own style (for all those thinking that Pranjal Bhaiya will write a poem, Dumit nhi sakega). He had two fields adjacent to each other, so he thought of digging a well in one of them so the other could get the water.
Every field in MATRIXLand is like a MATRIX A with N∗M cells. Each cell of the MATRIX has a water value which is already known. To dig a well, one needs to select a SUB-MATRIX.
Pranjal Bhaiya wants to know the expected water value if he digs a well at random, i.e. he selects any SUB-MATRIX at random. The water-value for the submatrix is the sum of the elements present in the SUB-MATRIX.
It can be proved that the expected sum can be represented in the form of a fraction PQ.
You have to print the value (P∗Q−1) % 1000000007.
Input:
First line contains the dimensions N∗M of the field.
The next N lines contain M numbers denoting the water value of each cell.
Output:
Output a single number denoting the answer in the given format.
Constraints:
1≤N,M≤2000
1≤A[i][j]≤1e18
Problem Setter: Kevin Mathew T
In the given matrix there are three possibilities. Either you choose submatrix containing only (1,1) with sum 1, submatrix containing only (1,2) with sum 1 or submatix consisting of (1,1) and (1,2) with sum 2.
Therefore,
ExpectedValue=13+13+23=43