eolymp
bolt
Try our new interface for solving problems
Problems

Figures Of Simple Sense

Figures Of Simple Sense

Do you think that drawing polygons is easy? This is not the case when you have some restrictions. In this problem all you have to do is just to draw a polygon. It must have exactly \textbf{N }vertices. It must contain no self-intersections. No three consecutive vertices of the polygon must be collinear. All coordinates of its vertices must be integers between \textbf{0} and \textbf{10 000}, inclusive. Easy, right? There is one more small restriction though. The number of inner angles of this polygon equal to \textbf{90°} must be as large as possible under these constraints. What do you think about it now? \InputFile Contains the number of test cases \textbf{T} (\textbf{1} ≤ \textbf{T} ≤ \textbf{30}) followed by \textbf{T} integer numbers \textbf{N} (\textbf{3} ≤ \textbf{N} ≤ \textbf{1000}). \OutputFile For each test case print the maximum possible number of inner angles equal to \textbf{90°} followed by \textbf{N} pairs of integers -the coordinates of the vertices of the polygon in either clockwise or counterclockwise order. Of course, more than one solution is possible, so output any of them.
Time limit 1 second
Memory limit 256 MiB
Input example #1
2
4
6
Output example #1
4
0 0
1 0
1 1
0 1

5
1 1
3 3
5 1
4 0
3 1
2 0
Author Gennady Korotkevich
Source Gennady Korotkevich Contest 1, Petrozavodsk Training Camp, Day 1, Friday, August 23, 2013