QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 100

#13523. Superknight

الإحصائيات

On an infinite chequered board there is a superknight which can make different moves. Each kind of move is described by two integers: the first tells how many columns (to the right if the number is positive or to the left if the number is negative) and the second tells how many rows (forward if the number is positive or backward if the number is negative) the knight traverses making such a move.

Task

Write a program which:

  • reads from the standard input sets of data describing different superknights,
  • determines for each superknight whether it is able to reach any square of the board making allowed moves,
  • writes the result to the standard output.

Input

In the first line of the standard input there is one integer $k$ denoting the number of sets of data, $1 \le k \le 100$. It is followed by k sets of data. In the first line of each set there is an integer $n$ being the number of kinds of the superknight's moves, $1 \le n \le 100$. Each of the following $n$ lines of the set contains two integers $p$ and $q$ separated by a single space, $-100 \le p,q \le 100$. These numbers describe one kind of move.

Output

The standard output should consist of $k$ lines. The $i$-th line should contain one word TAK ("yes"), if the superknight described by the $i$-th set of data is able to reach any square of the board, or the word NIE ("no") otherwise.

Example

Input

2
3
1 0
0 1
-2 -1
5
3 4
-3 -6
2 -2
5 6
-1 4

Output

TAK
NIE

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.