AtCoder Grand Contest 061
B
Summation By Construction
AtCoder
⌀ 3371
原题
← AC →
翻译中…

Problem Statement

翻译中…

There is a graph with $N$ vertices $v_1, \ldots, v_N$ on the left, and $N + 1$ vertices $u_1, \ldots, u_{N + 1}$ on the right. Each vertex $v_i$ ($1 \leq i \leq N$) is connected to each vertex $u_j$ ($1 \leq j \leq N + 1$), that is, the graph contains $N(N + 1)$ edges.

翻译中…

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

翻译中…

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

翻译中…
  • For each $i = 0, \ldots, 2k - 1$, vertices $w_i$ and $w_{i + 1}$ are connected with an edge of color $k$,
  • No other edges of color $k$ exist.
翻译中…

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

翻译中…

For each input file, solve $T$ test cases.

翻译中…

Constraints

翻译中…
  • $1 \leq T \leq 100$
  • $1 \leq N \leq 100$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

T
case_1
case_2
\vdots
case_T

翻译中…

Each case is in the following format:

翻译中…

N

翻译中…

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
C_{1, 1} C_{1, 2} \ldots C_{1, N + 1}
\vdots
C_{N, 1} C_{N, 2} \ldots C_{N, N + 1}

翻译中…

Here, $C_{i, j}$ is the color of the edge between $v_i$ and $u_j$.

翻译中…

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

翻译中…

样例

Input #1
2
1
2
Output #1
Yes
1 1
No
题目信息
题号
agc061_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。