1318. Polygons

单点时限: 2.0 sec

内存限制: 256 MB

Two players take part in the game polygons. A convex polygon with n vertices divided by n-3 diagonals into n-2 triangles is necessary. These diagonals may intersect in vertices of the polygon only. One of the triangles is black and the remaining ones are white. Players proceed in alternate turns. Each player, when its turn comes, cuts away one triangle from the polygon. players are allowed to cut off triangles along the given diagonals. The winner is the player who cuts away the black triangle.

NOTE: We call a polygon convex if a segment joining any two points of the polygon is contained in the polygon.

Task

Write a program which:

1.reads the description of the polygon,

2.verifies whether the player who starts the game has a winning strategy,

3.writes the result.

输入格式

The first line of the input contains an integer n, 4 <= n <= 50000. This is the number of vertices in the polygon. The vertices of the polygon are numbered, clockwise, from 0 to n-1.

The next n-2 lines comprise descriptions of triangles in the polygon. In the i+1-th line, 1 <= i <= n-2, there are three non-negative integers a, b, c separated by single spaces. Theses are numbers of vertices of the i-th triangle. The first triangle in a sequence is black.

输出格式

The output should have one line with the word:

1.TAK (means “yes” in Polish), if the player, who starts the game has a winning strategy,

2.NIE (means “no” in Polish), if he does not have a winning strategy.

样例

Input
6
0 1 2
2 4 3
4 2 0
0 5 4
Output
TAK

0 人解决,3 人已尝试。

0 份提交通过,共有 5 份提交。

9.9 EMB 奖励。

创建: 17 年,3 月前.

修改: 7 年,2 月前.

最后提交: 16 年,1 月前.

来源: POI 1999 I Stage

题目标签