You are given a matrix ‘MAT’ of dimensions ‘N x N’. Let’s define a sequence to be ‘zigzag’ if it starts from the top and ends at the bottom such that no two consecutive elements of the sequence belong to the same column.
Your task is to find the sum of the zigzag sequence with the largest sum.
Input Format :
The first line contains an integer ‘T’, which denotes the number of test cases to be run. Then, the T test cases follow.
The first line of each test case contains a single positive integer, ‘N’, as described in the problem statement.
The next ‘N’ lines of each test case contains ‘N’ space-separated number, ‘MAT[i][j]’, representing the value at index (i,j) of the matrix.
Output Format :
For each test case, print the “sum of the zigzag sequence with the largest sum”, as described in the problem statement.
Output for each test case will be printed in a separate line.
Note :
You do not need to print anything. It has already been taken care of. Just implement the given function.
Constraints :
1 <= T <= 10
1 <= N <= 100
1 <= MAT[i][j] <= 1000
Where 'MAT[i][j]' denotes the value of matrix at 'jth' column of 'ith' row.
Time Limit: 1sec