Bigger Square Please...

Tomy has many paper-squares. The side length(we call it 'size') of them range from 1 to N-1, and he has a really COUNTLESS squares of each kind. He used to be very proud of his squares, but one day, he suddenly wants to have a bigger one -- a square of size N! Though he doesn't have such a square, he can make it up with the squares he has. For example. A square of size 7 can be made up with 9 smaller squares, shown below.

Note that there should be NO empty space in the square, and NO extra paper outside the square, and the small squares should NOT overlap. As you may guess, Tomy wants to make it using the minimal number of squares he has, can you help?

Input

The first line of the input contains a single integer T, indicating the number of test cases. (1<=T<=20) Each case contains a single integer N. (2<=N<=50)

Output

For each test case in the input, print a line containing a single integer K, indicating the minimal number of squares needed to build the target square. In the following K lines, each contains three integers x,y,l indicating the coordinates of top-left corner, and the side length of the corresponding square. (1<=x,y<=N)

Sample Input

3
4
3
7

Sample Output

4
1 1 2
1 3 2
3 1 2
3 3 2
6
1 1 2
1 3 1
2 3 1
3 1 1
3 2 1
3 3 1
9
1 1 2
1 3 2
3 1 1
4 1 1
3 2 2
5 1 3
4 4 4
1 5 3
3 4 1

2个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐