There is a matrix of size
. Two distinct cells of the matrix and are painted with colors and 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 to (both inclusive).
- The number of distinct colors used is minimum (including and ).
Note:
- You cannot repaint the cells and .
- Two cells are adjacent if they share a common edge. Thus, for a cell there are adjacent cells. The adjacent cells are and .
Input Format
- First line will contain , number of test cases. Then the test cases follow. Each test case consists of lines.
- The first line contains two space seperated integers and denoting the dimensions of the matrix.
- The second line contains two integers and , denoting the coordinates of cell which is painted .
- The third line contains two integers and , denoting the coordinates of cell which is painted .
Output Format
For each test case, output lines, each consisting of space separated integers where integer in line denotes the color of cell in row and column of the matrix and must be in inclusive.
In case of multiple possible answers, output any.
Constraints
- Sum of over all test cases does not exceed .
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
Test Case :
The initially painted cells are and . One possible way is to paint the remaining cells with color . This way, no two adjacent cells have the same color.
Note that, instead of color , we can use any other color in the range except colors and .
The number of distinct colors used in this case is . It can be shown that the minimum number of distinct colors cannot be less than .
Test Case :
The initially painted cells are and . 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 . It can be shown that the minimum number of distinct colors cannot be less than .
ConversionConversion EmoticonEmoticon