题目描述
There is a matrix of size $N \times M.$ Two distinct cells of the matrix (x_{1}, y_{1}) and (x_{2}, y_{2}) are painted with colors $\text{1}$ and $\text{2}$ respectively.
You have to paint the remaining cells of the matrix such that:
No two adjacent cells are painted in same color.
Each color is an integer from 1 to 10^{9} (both inclusive).
The number of distinct colors used is minimum (including $\text{1}$ and $\text{2})$.
Note:
1. You cannot repaint the cells (x_{1}, y_{1}) and (x_{2}, y_{2}).
2. Two cells are adjacent if they share a common edge. Thus, for a cell (x,y) there are 4 adjacent cells. The adjacent cells are (x, y+1), (x, y-1), (x+1,y), and (x-1,y).
------ Input Format ------
- First line will contain T, number of test cases. Then the test cases follow. Each test case consists of 3 lines.
- The first line contains two space seperated integers N and M denoting the dimensions of the matrix.
- The second line contains two integers x_{1} and y_{1}, denoting the coordinates of cell which is painted $\text{1}$.
- The third line contains two integers x_{2} and y_{2}, denoting the coordinates of cell which is painted $\text{2}$.
------ Output Format ------
For each test case, output N lines, each consisting of M space separated integers where j^{th} integer in i^{th} line denotes the color of cell in i^{th} row and j^{th} column of the matrix and must be in [1, 10^{9}] inclusive.
In case of multiple possible answers, output any.
------ Constraints ------
$1 ≤ T ≤ 100$
$2 ≤ N, M ≤ 10^{5}$
$1 ≤ x_{1}, x_{2} ≤ N$
$1 ≤ y_{1}, y_{2} ≤ M$
$(x_{1}, y_{1}) \neq (x_{2}, y_{2})$
- Sum of $N \cdot M$ over all test cases does not exceed $10^{5}$.
----- Sample Input 1 ------
2
2 2
1 1
2 2
2 3
1 1
1 2
----- Sample Output 1 ------
1 4
4 2
1 2 1
2 1 2
----- explanation 1 ------
Test Case $1$:
The initially painted cells are $(1,1)$ and $(2,2)$. One possible way is to paint the remaining cells with color $4$. This way, no two adjacent cells have the same color.
Note that, instead of color $4$, we can use any other color in the range $[1, 10^{9}]$ except colors $1$ and $2$.
The number of distinct colors used in this case is $3$. It can be shown that the minimum number of distinct colors cannot be less than $3$.
Test Case $2$:
The initially painted cells are $(1,1)$ and $(1,2)$. One possible way is to paint the remaining cells as shown in the figure. This way, no two adjacent cells have the same color.
The number of distinct colors used in this case is $2$. It can be shown that the minimum number of distinct colors cannot be less than $2$.
输入格式
见题面
输出格式
见题面