W razie problemów technicznych ze Szkopułem, prosimy o kontakt mailowy pod adresem [email protected].
Jeśli chciałbyś porozmawiać o zadaniach, rozwiązaniach lub problemach technicznych, zapraszamy na serwery Discord. Są one moderowane przez społeczność, ale członkowie zespołu technicznego też są tam aktywni.
Two players take part in the game polygons. A convex polygon with vertices divided by diagonals into 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.
Write a program which:
The first line of the standard input contains an integer , . This is the number of vertices in the polygon. The vertices of the polygon are numbered, clockwise, from to . The next lines comprise descriptions of triangles in the polygon. In the -th line, , there are three non-negative integers , , separated by single spaces. Theses are numbers of vertices of the -th triangle. The first triangle in a sequence is black.
The standard output should have one line with the word:
For the input data:
6 0 1 2 2 4 3 4 2 0 0 5 4
the correct result is:
TAK
Task author: Grzegorz Jakacki.