#AGC061B. [AGC061B] Summation By Construction

[AGC061B] Summation By Construction

Score : 800800 points

Problem Statement

There is a graph with NN vertices v1,,vNv_1, \ldots, v_N on the left, and N+1N + 1 vertices u1,,uN+1u_1, \ldots, u_{N + 1} on the right. Each vertex viv_i (1iN1 \leq i \leq N) is connected to each vertex uju_j (1jN+11 \leq j \leq N + 1), that is, the graph contains N(N+1)N(N + 1) edges.

We color every edge with one of the NN colors 1,,N1, \ldots, N. A coloring is suitable if for each k=1,,Nk = 1, \ldots, N there are exactly 2k2k edges of color kk, and those edges form a simple path.

Formally, for each k=1,,Nk = 1, \ldots, N there should exist a sequence of distinct vertices w0,,w2kw_0, \ldots, w_{2k} such that all of the following is true:

  • For each i=0,,2k1i = 0, \ldots, 2k - 1, vertices wiw_i and wi+1w_{i + 1} are connected with an edge of color kk,
  • No other edges of color kk exist.

Find any suitable coloring, or determine that it doesn't exist.

For each input file, solve TT test cases.

Constraints

  • 1T1001 \leq T \leq 100
  • 1N1001 \leq N \leq 100

Input

Input is given from Standard Input in the following format:

TT

case1case_1

case2case_2

\vdots

caseTcase_T

Each case is in the following format:

NN

Output

For each test case, if a suitable coloring does not exist, print No. Otherwise, print a suitable coloring description in the following format:

Yes

C1,1C_{1, 1} C1,2C_{1, 2} \ldots C1,N+1C_{1, N + 1}

\vdots

CN,1C_{N, 1} CN,2C_{N, 2} \ldots CN,N+1C_{N, N + 1}

Here, Ci,jC_{i, j} is the color of the edge between viv_i and uju_j.

If there are many suitable colorings, print any of them.

2
1
2
Yes
1 1
No