There is a grid of $$$3n \times 3n$$$ points, consisting of all integer points $$$(x,y)$$$ such that $$$1 \le x,y \le 3n$$$.
Find a largest set of triangles satisfying the following conditions:
If there exist multiple largest such sets of triangles, you may output any of them.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 30$$$). The description of the test cases follows.
The only line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 166$$$).
It is guaranteed that the sum of $$$n^2$$$ over all test cases does not exceed $$$166^2$$$.
Output the maximum size $$$m$$$ of the set of triangles on one line ($$$0 \le m \le 3n^2$$$).
Then, output $$$m$$$ lines in the following format:
You may output the vertices of one triangle in any order (clockwise or counterclockwise).
Your output will be accepted if it satisfies all conditions and the maximum size given is correct.
212
2 1 1 1 2 2 1 2 3 3 2 3 3 12 1 1 1 2 2 1 2 2 3 2 3 1 1 3 1 4 2 3 2 4 3 4 3 3 1 5 1 6 2 5 2 6 3 6 3 5 4 1 4 2 5 1 5 2 6 2 6 1 4 3 4 4 5 3 5 4 6 4 6 3 4 5 4 6 5 5 5 6 6 6 6 5
In the first test case, the example output has $$$2$$$ triangles as shown in the following image:
In the second test case, the example output has $$$12$$$ triangles as shown in the image on the left:
![]() | ![]() |
As the triangles are not required to be right triangles, the set of triangles shown in the image on the right will also be considered valid.