 Maximum sum of hour glass
##### Submissions: 1037   Accuracy: 31.02%   Difficulty: Basic   Marks: 1

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

#### ** For More Input/Output Examples Use 'Expected Output' option **

Author: Shubham Joshi 1

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.