Merge the squares!
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
Special Judge, 64bit IO Format: %lld

题目描述

Just like all math-loving students, Bobo loves squares, especially big ones, and he loves to combine many small squares into a big one. “Exactly. That's why I drew squares on my algebra exam,” Bobo explained to his algebra professor.



Algebraically,right?

Because of this, Bobo is also interested in perfect squared squares, which are squares that can be dissected into smaller squares of different sizes. The smallest order for a perfect squared square is 21, discovered by A. J. W. Duijvestijn.



Perfect Squared square of order 21


However, it's too difficult for Bobo to assemble squares of different sizes into a big square, so he wants to start with something simpler, like assembling n\times n small squares with side length 1 into a big square with side length n. Of course, Bobo cannot use only one operation to assemble all the squares together, or it would be too boring. He now has a new requirement: the number of squares merged each time must be between 2 and 50 (inclusive), and the resulting shape must still be a square. 

Bobo doesn't know how to proceed, so he has given this problem to you. It is guaranteed that under the constraint of this problem, a valid sequence of operations always exists.

输入描述:

The only line contains an integer n (1\leq n\leq 1000), denoting the number of rows and columns of the small squares.

输出描述:

Output a number m (0\leq m\leq 10^6) in the first line, representing the number of operations. In the next m lines, output three numbers x, y and k per line, representing one operation. Here, 1\leq x\leq n and 1\leq y\leq n represent the row number and column number of the upper-left corner of the merged large square after this operation (1-n is used to represent the row number and column number), and 1\leq k\leq n represents the side length of the merged large square. You need to ensure that each of your operations satisfies the following conditions:
1.   x+k-1\leq n,y+k-1\leq n
2.   The square with side length k whose upper-left corner is in cell (x,y) contains only complete squares, and the number of squares is between 2 and 50.

You also need to ensure that after all the operations are completed, all n \times n small squares with a side length of 1 will be pieced together to form a large square with a side length of n. If there are multiple valid sequence of operations, you may output any of it. Refer to the notes section for more information.
示例1

输入

复制
1

输出

复制
0
示例2

输入

复制
2

输出

复制
1
1 1 2
示例3

输入

复制
8

输出

复制
5
1 1 4
1 5 4
5 1 4
5 5 4
1 1 8

备注:

To aid understanding, we provide graphical illustrations for the third sample test. The merging process in the solution for the third example is shown below (purple represents the area merged each time).