Polish version    English version  
  History of OI -> IX OI 2001/2002 -> Problems


 News
 About Olympic
 History of OI
XVII OI 2009/2010
XVI OI 2008/2009
XV OI 2007/2008
XIV OI 2006/2007
XIII OI 2005/2006
XII OI 2004/2005
XI OI 2003/2004
X OI 2002/2003
IX OI 2001/2002
Schedule
Problems
Stage III - results
Stage II - results
Stage I - results
Stage II
Rules
For contestants
Helpful resources
Stats
VIII OI 2000/2001
VII OI 1999/2000
VI OI 1998/1999
V OI 1997/1998
IV OI 1996/1997
III OI 1995/1996
II OI 1994/1995
I OI 1993/1994
 OI books
 National team
 Olympic camps
 Photo gallery
 Links
 SIO
 MAIN
IX Olimpiada Informatyczna 2001/2002

Task: sup
Author: Krzysztof Onak
Superknight

I stage contest  

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 text file sup.in 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 text file sup.out.

Input

In the first line of the text file sup.in there is one integer k denoting the number of sets of data, 1<=k<=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<=n<=100. Each of the following n lines of the set contains two integers p and q separated by a single space, -100<=p,q<=100. These numbers describe one kind of move.

Output

The text file sup.out 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

For the following input file sup.in:
2
3
1 0
0 1
-2 -1
5
3 4
-3 -6
2 -2
5 6
-1 4
the correct answer is in the following output file sup.out:
TAK
NIE



Print friendly version