M. Matrix Construction
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Constructing a matrix, and the sample includes a test case "2 3"... Haven't we seen a problem like this recently?
—Stewed-chicken

Mary loves constructing matrices!

Today, Mary wants to fill a permutation$$$^{\dagger}$$$ of length $$$n \times m$$$ into an $$$n \times m$$$ matrix $$$A$$$, such that the sum of any two adjacent elements is unique.

In other words, for any $$$1 \leq x_1,x_2,x_3,x_4 \leq n, 1 \leq y_1,y_2,y_3,y_4 \leq m$$$, if all of the following conditions are satisfied:

  • $$$x_2 \geq x_1, y_2 \geq y_1, x_4 \geq x_3, y_4 \geq y_3$$$;
  • $$$|x_2-x_1|+|y_2-y_1|=1, |x_4-x_3|+|y_4-y_3|=1$$$;
  • $$$(x_1,y_1) \neq (x_3,y_3)$$$ or $$$(x_2,y_2) \neq (x_4,y_4)$$$;
then: $$$$$$ A_{x_1,y_1}+A_{x_2,y_2} \neq A_{x_3,y_3}+A_{x_4,y_4} $$$$$$

For example, when $$$n=2$$$ and $$$m=3$$$, matrix $$$B$$$ is a valid solution, while matrix $$$C$$$ is not valid because $$$C_{1,1}+C_{2,1}=C_{1,2}+C_{1,3}$$$.

$$$$$$ B = \begin{bmatrix} 1 & 3 & 2 \\ 6 & 5 & 4 \end{bmatrix}, \quad C = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix} $$$$$$

Given $$$n$$$ and $$$m$$$, can all the conditions above be satisfied? If so, output a valid solution.

$$$^{\dagger}$$$ A permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2,3,1,5,4]$$$ is a permutation, but $$$[1,2,2]$$$ is not a permutation ($$$2$$$ appears twice in the array), and $$$[1,3,4]$$$ is also not a permutation ($$$n=3$$$ but there is a $$$4$$$ in the array).

Input

Each test file contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \leq T \leq 10^4$$$). The description of the test cases follows.

The first line contains two integers $$$n,m$$$ ($$$1 \leq n,m \leq 1000$$$).

For each test file, it is guaranteed that the sum of $$$n \times m$$$ over all test cases does not exceed $$$10^6$$$.

Output

For each test case, output on the first line whether a valid solution exists. If there is a valid solution, output "Yes"; otherwise, output "No". You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

If a valid solution exists, you must also output $$$n$$$ lines, each containing $$$m$$$ integers. The $$$j$$$-th number on the $$$i$$$-th line represents the number at row $$$i$$$ and column $$$j$$$ in the matrix. You must make sure that the output numbers form a permutation of length $$$n \times m$$$. If there are multiple solutions, you may print any of them.

Example
Input
2
1 1
2 3
Output
yEs
1
YES
1 3 2
6 5 4