“Uban game world” is an indoor gaming zone. It offers game segments for only one ticket. Today, Aliban is going to participate in one of the games called “Greedy Grid Game”.
This game is about an grid. Each cell contains an integer value . Here denotes the number in the row from the top and column from the left. Aliban has to start the journey from and finish at . She can’t move any cell as she pleases. There are some rules that follows -
If she starts her movement by going right, i.e., to , then she is not allowed to stop until she reaches the border cell of the grid.
If she starts her movement by going down, i.e., to , then she is not allowed to stop until she reaches the border cell of the grid.
She is allowed to give at most one diagonal move in her whole journey. For example, to , to , to , to .
She is not allowed to visit any cell more than once.
Except for the diagonal moves, she cannot move left or up.
She can not move outside of the grid.
The score of Aliban will be the sum of cell values she visits throughout her journey.
As Aliban is not an expert in calculation she asks for your help. You have to find the maximum score she can achieve without violating any rules.
The input consists of multiple test cases. The first line contains an integer — the number of test cases. The description of the test cases follows.
The first line of each test case contains two positive integers and — the number of rows and columns respectively.
The following lines contain integers each, the element in the line holds the value .
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, print the maximum score Aliban can achieve.
Input | Output |
---|---|
2 3 3 1 2 2 1 10 -2 2 -3 1 3 3 -1 2 3 -4 5 6 10 2 3 | 14 19 |
In the first test case, to achieve the best score her movement should be |