Time Limit: Java: 2000 ms / Others: 2000 ms

Memory Limit: Java: 65536 KB / Others: 65536 KB

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?

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)

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)

提交代码