You work for a well-known department store that uses leading technologies and employs mechanistic work — that is, robots!
The department you work in sellsitems. The first item costs dollar, the second item costs dollars, and so on: -th item costs dollars. The items are situated on shelves. The items form a rectangular grid: there are shelves in total, and each shelf contains exactly items. We will denote by the price of -th item (counting from the left) on the -th shelf, .
Occasionally robots get curious and ponder on the following question: what is the mean price (arithmetic average) of itemsfor some shelf and indices ? Unfortunately, the old robots can only work with whole numbers. If the mean price turns out not to be an integer, they break down.
You care about robots’ welfare. You want to arrange the items in such a way that the robots cannot theoretically break. Formally, you want to choose such a two-dimensional arraythat:
- Every number from to (inclusively) occurs exactly once.
- For each , the mean price of items from to on -th shelf is an integer.
Find out if such an arrangement is possible, and if it is, give any example of such arrangement.
The first line contains a single integer( ) — the number of test cases.
The first and only line of each test case contains two integersand ( ) — the number of shelves and length of each shelf, respectively.
It is guaranteed that the sumover all test cases does not exceed and the sum over all test cases does not exceed .
Print the answer for each test case.
If such an arrangement exists, print “YES” on a single line. After that, print any example onlines of numbers each, one line per shelf. Each number from to must occur exactly once in the output.
If no good arrangement exists, print a single word “NO” on its own line.
4 1 1 2 2 3 3 3 1
YES 1 YES 1 3 2 4 NO YES 1 2 3