Given a 2D matrix, the task is to find maximum sum of a hour glass.
An hour glass is made of 7 cells
in following form.
A B C
D
E F G
Examples:
Input : 1 1 1 0 0
0 1 0 0 0
1 1 3 0 0
0 0 0 2 0
0 0 0 0 4
Output : 9
Below is the hour glass with
maximum sum:
3 0 0
2
0 0 4
Input:
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains two space separated integers N and M denoting the size of the matrix. Then in the next line are N*M values of the matrix (m).
Output:
For each test case in a new line print the required output.
Constraints:
1<=T<=100
1<=N,M<=20
1<=m[][]<1000
Example:
Input:
2
1 2
1 2
3 3
1 1 1 1 1 1 1 1 1
Output:
-1
7
11620078 | 164 |
RohitBattu | 127 |
Maninder07 | 126 |
blackshadows | 120 |
Rags Bhasin | 110 |
blackshadows | 880 |
xmyqsh | 565 |
mb1973 | 439 |
aman19 | 402 |
shubhamjain237 | 376 |
akhayrutdinov | 5014 |
Ibrahim Nash | 4899 |
Quandray | 4338 |
sanjay05 | 3668 |
blackshadows | 3384 |