7480: Last Problem

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:Special Judge 上传者:
提交:9 通过:8

题目描述

It's the night before Zhang3's birthday, and she's preparing for her birthday party in the classroom. She has brought a huge birthday cake and some powerful tomatoes, and has decorated almost every corner of the classroom. However, the blackboard is still empty. The last thing to do is to draw a beautiful pattern on it.

The blackboard is regarded as an infinite plane, each integer point (x,y) has an integer value as its color. At the very beginning, the color of every point is 0.

Zhang3 has n crayons, labeled 1,2,…,n. Painting with the ith crayon, you can replace the color of some chosen integer point (x,y) with color i. It is called a step, and she will draw the pattern step by step.

According to Zhang3's judgement of beautiful patterns, there's a restriction: Just before you paint (x,y) into some color i, the last four colors of i must appear among the adjacent points of (x,y). The last four colors of i means colors from (i−4) to (i−1), ignoring those non-positive ones. Two integer points are adjacent if their Euclid distance is exactly one. (Note that a point is not adjacent to itself.) If the condition above is not satisfied, the step is not allowed.

Zhang3 doesn't want to waste crayons, so the final pattern should contain at least one point with color n. Please help her find a way to draw such a beautiful pattern.
这是张3生日的前一天晚上,她正在教室里准备她的生日派对。她带来了一个巨大的生日蛋糕和一些强效的西红柿,并装饰了教室的几乎每个角落。然而,黑板仍然是空的。最后要做的就是在上面画一个漂亮的图案。



黑板被视为一个无限平面,每个整定点(x,y)都有一个整数值作为它的颜色。一开始,每个点的颜色都是0。



Zhang3有n支蜡笔,标记为1,2,…,n。用第i支蜡笔画画,你可以用颜色i代替一些选定的整数点(x,y)的颜色。这被称为一步,她会一步一步地画出图案。



根据Zhang3对美丽图案的判断,有一个限制:就在你把(x,y)画成某种颜色i之前,i的最后四种颜色必须出现在(x,y)的相邻点之间。i的最后四种颜色表示从(i−4)到(i−1)的颜色,忽略那些非正的颜色。如果两个整数点的欧几里得距离恰好为一,则它们是相邻的。(请注意,点不与其相邻。)如果不满足上述条件,则不允许执行该步骤。



Zhang3不想浪费蜡笔,所以最终的图案应该至少包含一个颜色为n的点。请帮助她找到一种方法来画出如此美丽的图案。


输入格式

The only line of the input contains an integer n(1≤n≤100), the number of crayons.


输入的唯一一行包含整数n(1≤n≤100),即蜡笔的数量。

输出格式

Print the steps in chronological order, each in a separate line. Notice that you should not print the number of steps.

In the ith line, print three integers xi,yi,ci, separated by spaces, indicating the ith step is to paint (xi,yi) into color ci.

Your answer should satisfy |xi|,|yi|≤109,1≤ci≤n. The number of steps should not exceed 105. The output file should not be larger than 5MB.

It can be proved that there is always a solution. Any solution that meets all of the requirements will be accepted.
按时间顺序打印步骤,每一步都在单独的一行中。请注意,您不应该打印步骤数。
在第i行中,打印三个整数xi、yi、ci,用空格隔开,表示第i步是将(xi、yi)绘制成颜色ci。
你的答案应该满足|xi|,|yi|≤109,1≤ci≤n。步骤数不应超过10^5。输出文件不应大于5MB。
可以证明,总是有解决方案的。任何满足所有要求的解决方案都将被接受。


输入样例 复制

4

输出样例 复制

0 0 1
1 0 1
0 1 2
1 1 3
1 -1 2
1 0 4

数据范围与提示

1st step: paint (0, 0) into color 1.
000
010
000
2nd step: paint (1, 0) into color 1.
0000
0110
0000
3rd step: paint (0, 1) into color 2.
0000
0200
0110
0000
4th step: paint (1, 1) into color 3.
0000
0230
0110
0000
5th step: paint (1, -1) into color 2.
0000
0230
0110
0020
0000
6th step: paint (1, 0) into color 4.
0000
0230
0140
0020
0000