The governor of Yekaterinozavodsk region had to deal with ambassadors from one
of the nearby states — Square country. All square inhabitants of this country
loved the squares of integers. So, they declared to the governor that
they would build a square metropolitan from Yekaterinozavodsk to one of the
suburbs only if he would be able to fill a rectangular table N × M with
squares of different positive integers in such a way, that the sum of numbers
in each row and in each column would also be a square. The governor wasn't a
square man, and also he wasn't good in maths, so he asked for your help.
Input
The first line contains an integer T — the number of test cases
(1 ≤ T ≤ 20). The following T lines contain the pairs of integers N and M
(1 ≤ N, M ≤ 20).
Output
For each test case output the required table: N lines with M numbers
in each line. All numbers in the table shouldn't exceed 1017. If there is no
such table, output −1. Answers for different test cases should be delimited
with an empty line.
Sample
input | output |
---|
3
1 2
3 1
2 2
| 9 16
1024
25
274576
4761 8464
627264 1115136
|
Problem Author: Ivan Burmistrov (prepared by Alexander Ipatov)
Problem Source: Ural SU Contest. Petrozavodsk Winter Session, January 2008