Given amatrix mat[][] of size N x N. The task is to print the elements of the matrix in the snake pattern.

Input:
First line consists of an integer T denoting the number of test cases. First line of each test case consists of N, denoting number of elements(N x N) in Matrix. Second line of every test case consists of N x N spaced integers denoting elements of Matrix elements.

Output:
For each testcase, in a new line, print the matrix in snake pattern.

Constraints:
1 <= T <= 100
1 <= N <= 100
1 <= mat[i][j] <= 100