P15695 [2018 KAIST RUN Spring] PuyoPuyo
Description
:::align{center}

Figure: Screenshot of PuyoPuyo game. This game uses $12 \times 6$ grid. There are $4$ kinds of color.
:::
PuyoPuyo is a famous series video game made by Compile Co., Ltd.. First game was released in 1991. The company defunct at 2003, but
PuyoPuyo team is still making game in Sonic Team™ to this day, 2018.
PuyoPuyo is a 2 player battle game. Each player plays by placing Puyo to grid. The detailed game rule is as follows:
- The game starts with an empty grid.
- Puyo is a round, slime-like object that falls from above to below of the grid.
- Each Puyo has a color.
- There are $K$ kinds of color of Puyo.
- Puyos are controlled as a pair (two Puyos).
- Puyo pair can be moved, dropped or rotated using a game controller.
- At the topmost part of the screen, Puyo pair can be moved horizontally, and can be rotated in horizontal or vertical direction.
- When you drop the Puyo, it each Puyo drops separately, until it reaches another Puyo or the bottom of the grid.
- You can place Puyo outside of the grid, but only over the grid.
- More than four Puyos that have same colors and shares an edge is called **Group**, and such groups are removed. This process is called **Popping**.
- If dropping a Puyo pair makes two or more groups, it is popped simultaneously.
- After group pops, remaining Puyos fall to another Puyo or the bottom of the grid. If it makes a new group, same procedure is repeated. This process is called **Chain**.
- During chains, you cannot place another Puyo pair.
Sonic Team™ requested your help to make PPAP (Puyo Puyo Algorithm for Printing). This will not be used in game software but will be used in special ceremonies.
You are given $R \times C$ grid. Each grid is filled with certain color of Puyo or an empty grid. You should drop Puyo pair and derive a given grid. In the final state, every Puyo should be in the grid.
Fortunately, you can choose which color and place to drop.
Input Format
Input consists of $R + 1$ lines.
First line contains three space-separated integers $R$, $C$ and $K$.
Next $R$ lines contain the final grid. Each line contains $C$ number of space-separated integers. Each color is represented by an integer 1 through $K$. 0 means an empty grid.
A given final grid can be made by no more than 250 Puyo pair drops.
Output Format
In the first line, you have to print the number of Puyo pair $D$.
In following $D$ lines, print four space-separated integers in each line.
- If you place Puyo pair horizontally, the first number is 0. If you place vertically, the first number is 1.
- Second number represents the row number of the left Puyo.
- Third number represents the color of left or upper Puyo of the pair.
- Fourth number represents the color of right or lower Puyo of the pair.
Explanation/Hint
In this example, Puyos are dropped like following:
:::align{center}

:::
### Constraints
- $3 \le K \le 6$
- $R = C = 4$ or $R = C = 20$
- $D \le 250$ (You have to use 250 or less Puyo pairs.)