JCB KI KHUDAI

0

0 votes
Probablity, Matrix
Problem

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  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 .

You have to print the value  % .

Input:

First line contains the dimensions  of the field.

The next  lines contain  numbers denoting the water value of each cell.

Output:

Output a single number denoting the answer in the given format.

Constraints:

 

Problem Setter: Kevin Mathew T

 

Sample Input
1 2
1 1
Sample Output
333333337
Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

In the given matrix there are three possibilities. Either you choose submatrix containing only  with sum , submatrix containing only  with sum  or submatix consisting of  and with sum .

Therefore,  

Editor Image

?