Topic background
Always thinking little odd strange questions in math class.
Title Description
Given a $ n \ times m $ matrix, each element of the matrix $ a_ {i, j} $ is a positive integer.
The next provision:
$ 1 $ lawful path initial departure from the top left corner of the matrix, you can only go to the right or down and finish at the bottom right corner.
2. $ $ path passes $ n + m-1 $ lattices of elements $ A_1, A_2 ... A _ { (n + m-1)} $, $ Aavg $ $ A_i is an average of $ path the value of $ V $ $ (n + m-1) \ times \ sum \ limits_ {i = 1} ^ {n + m-1} {(A_i-Advg)} ^ 2 $
required minimum value $ $ V legal path, the output value to $ V $, multiple sets of test data.
Input Format
The first line contains a positive integer $ T $, represents the number of data sets.
For each set of data:
The first line contains two positive integers n-$ $ and $ m $, it represents the number of rows and columns of the matrix.
Next, n-$ $ lines of positive integers $ m $ $ a_ {i, j} $ , this matrix is described.
Output Format
For each query, a line output integer results required.
Sample
Sample input:
1
2 2
1 2
3 4
Sample output:
14
Data range and tips
For $ 30 \% $ data $ n \ leqslant 10 $, $ m \ leqslant 10 $.
Further there is $ 40 \% $ data $ n \ leqslant 15 $, $ m \ leqslant 15 $, the matrix element is not greater than $ 5 $.
For $ 100 \% $ data $ T \ leqslant 5 $, $ n \ leqslant 30 $, $ m \ leqslant 30 $, the matrix element is not greater than $ 30 $.
answer
It is a mathematical headache