Confusing Puzzle
题号:NC243971
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld

题目描述

Inspired by the 15-puzzle, Cuber QQ invents a new puzzle game, named confusing puzzle, as it always makes players confused.

The puzzle is a parallelogram, which contains vertices. We'll consider the parallelogram rows numbered from bottom to top 1 through n, and the columns numbered from left to right 1 through m. Then we'll denote the position of vertices in row x and column y as (x,y) and its initial id is .

The following figure shows the initial parallelogram:



Each time, the player can operate the parallelogram in the following two ways:

  • , select an \textbf{upright} equilateral triangle (positions of vertices on it is and ) and rotate it clockwise.
  • , select a diamond (positions of vertices on it is and ) and rotate it clockwise.


Cuber QQ will give you a scrambled puzzle, and ask you to restore it within operations.

输入描述:

First line contains two integers n,m ((2\le n,m\le 100)).

The following n lines, each line contains m integres, denotes the vertices id in the scrambled puzzle.

输出描述:

In the first line, you should output an integer T, which is the number of operations.

The following T lines, each line contains three integers opt,x,y.

  • opt=1, the operation is selecting an upright equilateral triangle (positions of vertices on it is (x,y),(x+1,y) and (x,y+1)) and rotate it clockwise.
  • opt=2, the operation is selectng a diamond (positions of vertices on it is (x,y),(x+1,y),(x,y+1) and (x+1,y+1)) and rotate it clockwise.

It is guaranteed that the scrambled puzzle has at least one solution.

If there are multiple answers, print any.
示例1

输入

复制
2 3
4 1 2
5 6 3

输出

复制
2
1 1 1
2 1 2

说明