Universal Cup Judging System

Universal Cup

実行時間制限: 1.0 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓
統計

In this problem, you will need to construct a grid with $n$ rows and $n$ columns. Each cell of the grid has an integer in it, where $a_{i,j}$ indicates the integer in the cell located at the $i$-th row and the $j$-th column. Each integer from $1$ to $n^2$ (both inclusive) appears exactly once in the grid.

We say an integer $x$ is a “bingo integer” of this grid, if at least one of the two following conditions is satisfied:

  • There is at least one row, where all integers in the cells of that row are less than or equal to $x$.
  • There is at least one column, where all integers in the cells of that column are less than or equal to $x$.

It is easy to see that a grid may have multiple bingo integers, however in this problem, we’re only interested in the smallest bingo integer.

Given integers $n$ and $k$, construct a grid with $n$ rows and $n$ columns, such that its smallest bingo integer is exactly $k$.

Input

There are multiple test cases. The first line of the input contains an integer $T$ ($1 \le T \le 50$) indicating the number of test cases. For each test case:

The first and only line contains two integers $n$ and $k$ ($1 \le n \le 50$, $1 \le k \le n^2$).

Output

For each test case:

  • If it is possible to construct a grid with $n$ rows and $n$ columns, such that its smallest bingo integer is $k$, first output Yes in one line. Then output $n$ lines, where the $i$-th line contains $n$ integers $a_{i,1}, a_{i,2}, \dots, a_{i,n}$ separated by a space, indicating the integers on the $i$-th row of the grid. Don’t forget that each integer from $1$ to $n^2$ (both inclusive) must appear exactly once in the grid. If there are multiple valid answers, you can output any of them.
  • If it is impossible to find an answer, just output No in one line.

Examples

Input 1

4
3 5
4 10
5 2
1 1

Output 1

Yes
4 2 5
7 1 9
8 6 3
Yes
14 9 2 13
1 11 16 8
10 3 7 5
6 15 4 12
No
Yes
1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.