题目描述
Construct an $N \times M$ matrix with entries having positive integers such that:
If M > 1, i^{th} row is strictly increasing from left to right with a fixed common difference d_{i} for all 1≤ i ≤ N.
If N > 1, j^{th} column is strictly increasing from top to bottom with a fixed common difference c_{j} for all 1≤ j ≤ M.
All the common differences should be distinct.
In the case of multiple answers, find an arrangement that minimizes the maximum element of the matrix.
------ Input Format ------
- First line will contain T, number of test cases. Then the test cases follow.
- Each test case contains a single line of input, two space-separated integers N and M - the dimensions of the matrix.
------ Output Format ------
For each test case, output N lines with each line having M space-separated integers representing the answer.
------ Constraints ------
$1 ≤ T ≤ 10$
$1 ≤ N, M ≤ 10^{5}$
- Sum $N \cdot M$ over all cases is atmost $10^{5}$.
----- Sample Input 1 ------
3
3 3
1 2
1 1
----- Sample Output 1 ------
1 2 3
3 6 9
5 10 15
1 2
1
----- explanation 1 ------
Test case $1$: The values $d_{1}, d_{2},$ and $d_{3}$ are $1, 3,$ and $5$ respectively. The values $c_{1}, c_{2},$ and $c_{3}$ are $2, 4,$ and $6$ respectively. Note that all these common differences $\{d_{1}, d_{2}, d_{3}, c_{1}, c_{2}, c_{3}\}$ are distinct. Moreover, it can be shown that over all valid matrices, $15$ is the minimal value of the maximum element of the matrix one can achieve.
Test case $2$: The values $d_{1}$ is $1$. It can be shown that over all valid matrices, $2$ is the minimal value of the maximum element of the matrix one can achieve.
输入格式
见题面
输出格式
见题面