CF2094C.Brr Brrr Patapim

传统题 时间 2000 ms 内存 256 MiB 4 尝试 1 已通过 1 标签

Brr Brrr Patapim

Brr Brrr Patapim is trying to learn of Tiramisù's secret passcode, which is a permutation^{\text{∗}} of 2n2\cdot n elements. To help Patapim guess, Tiramisù gave him an n×nn\times n grid GG, in which Gi,jG_{i,j} (or the element in the ii-th row and jj-th column of the grid) contains pi+jp_{i+j}, or the (i+j)(i+j)-th element in the permutation.

Given this grid, please help Patapim crack the forgotten code. It is guaranteed that the permutation exists, and it can be shown that the permutation can be determined uniquely.

^{\text{∗}}A permutation of mm integers is a sequence of mm integers which contains each of 1,2,,m1,2,\ldots,m exactly once. For example, [1,3,2][1, 3, 2] and [2,1][2, 1] are permutations, while [1,2,4][1, 2, 4] and [1,3,2,3][1, 3, 2, 3] are not.

Input

The first line contains an integer tt — the number of test cases (1t2001 \leq t \leq 200).

The first line of each test case contains an integer nn (1n8001 \leq n \leq 800).

Each of the following nn lines contains nn integers, giving the grid GG. The first of these lines contains G1,1,G1,2,,G1,nG_{1,1}, G_{1,2},\ldots,G_{1,n}; the second of these lines contains G2,1,G2,2,,G2,nG_{2,1}, G_{2,2},\ldots,G_{2,n}, and so on. (1Gi,j2n1 \leq G_{i,j} \leq 2\cdot n).

It is guaranteed that the grid encodes a valid permutation, and the sum of nn over all test cases does not exceed 800800.

Output

For each test case, please output 2n2n numbers on a new line: p1,p2,,p2np_1,p_2,\ldots,p_{2n}.

Samples

3
3
1 6 2
6 2 4
2 4 3
1
1
2
2 3
3 4
5 1 6 2 4 3 
2 1 
1 2 3 4 

在线编程 IDE

建议全屏模式获得最佳体验