#P11021. [2016杭电多校]Gambler Bo
[2016杭电多校]Gambler Bo
Gambler Bo
Problem Description
Gambler Bo is very proficient in a matrix game. You have a matrix, every cell has a value in . In this game, you can choose a cell in the matrix, plus 2 to this cell, and plus 1 to all the adjacent cells. for example, you choose the cell , the value of will be plused 2, and the value of will be plused 1. if you choose the cell , the cell will be plused 2, and the cell will be plused 1, the cell won't be changed because it's out of the matrix. If the values of some cells is exceed 2, then these values will be modulo 3. Gambler Bo gives you such a matrix, your task is making all value of this matrix to 0 by doing above operations no more than times.
Input
First line, an integer . There are test cases. In each test, first line is two integers , and following lines describe the matrix of this test case. , the matrix is random and guarantee that there is at least one operation solution.
Output
For each test, first line contains an integer describing the operation times. Following lines, each line contains two integers describing the operation cell. The answer may not be unique, you can output any one.
Sample Input
2
2 3
2 1 2
0 2 0
3 3
1 0 1
0 1 0
1 0 1
Sample Output
1
1 2
5
1 1
1 3
2 2
3 1
3 3
Author
绍兴一中
Source
2016 Multi-University Training Contest 3