

If the grid is:
1 2
3 4
We can collect points from all cells as each cell lies on a diagonal. So, the maximum points will be 1+2+3+4 = 10.
The first line contains 'T', denoting the number of test cases.
For each Test :
The first line contains an integer ‘N’.
The next ‘N’ lines contain ‘N’ space separated integers each, representing the grid.
Print one integer, the maximum number of points you can gain from the grid.
You are not required to print the expected output. It has already been taken care of. Just implement the function.
1 <= 'T' <= 10
1 <= ‘N’ <= 1000.
1 <= ‘A[i][j]’ <= 1000, i ∈ [1,N], j ∈ [1,N]
Note: It is guaranteed that the sum of N^2 across all test cases will be at most 10^6.
Time Limit: 1 sec
We iterate over all the elements in the grid and check if the current element is present on at least one of the diagonals or not. If it is on one of the diagonals, we can add it the the answer.
We can first iterate over all the elements on the principal diagonal of the grid and add them to the answer variable. Then we can iterate over all the elements in the secondary diagonal and add them to the answer variable.
In cases where ‘N’ is odd, the middle element in the grid (middle row, middle column) is part of both the principal and secondary diagonal and gets added twice. Hence in this case, we must subtract the middle element from the answer variable.