#P8854. [POI 2002 R1] 超级马
[POI 2002 R1] 超级马
Problem Description
On an infinite chessboard, there is a super knight that can perform various moves.
Each move consists of two integers. The first number indicates how many squares it moves up or down, and the second number indicates how many squares it moves left or right. Move the knight to perform this move. (Positive numbers mean moving to the right, and negative numbers mean moving to the left.)
For each given super knight, determine whether it can reach every position on the chessboard.
Input Format
The first line contains an integer , the number of test cases.
For each test case, the first line contains an integer , the number of moves the super knight can perform.
The next lines each contain two integers and , describing one move.
Output Format
Output lines. If the super knight can reach every position on the chessboard, output TAK, otherwise output NIE.
2
3
1 0
0 1
-2 -1
5
3 4
-3 -6
2 -2
5 6
-1 4
TAK
NIE
Hint
Constraints: , .
Translated by ChatGPT 5