Polish version    English version  
  History of OI -> VII OI 1999/2000 -> 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
VIII OI 2000/2001
VII OI 1999/2000
Stage III - results
Stage II - results
Stage I - results
Problems
Regulations
Organization
Hints
Schedule
Stats
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
Niebieskie ksi.eczki
VII Olimpiada Informatyczna 1999/2000

Task: WIR
Author: Wojciech Rytter
Viruses

I stage contest  

Binary Viruses Investigation Committee detected, that certain sequences of zeroes and ones are codes of viruses. The committee isolated a set of all the virus codes. A sequence of zeroes and ones is called safe, if any of its segments (i.e. sequence of consecutive elements) is not a virus code. The committee is aiming at finding, whether an infinite, safe sequence of zeroes and ones exists.

Example

For a set of codes {011, 11, 00000}, the sample infinite safe sequence is 010101... . For a set of codes {01, 11, 00000} an infinite safe sequence of zeroes and ones does not exist.

Task

Write a program, which:

  • reads virus codes from the text file WIR.IN,
  • determines, whether an infinite, safe sequence of zeroes and ones exists
  • writes the result to the text file WIR.OUT.

Input

The first line of the input file WIR.IN consists of one integer n standing for the number of all virus codes. Each of the next n lines consists of one non-empty word composed from 0s and 1s - a virus code. The total length of all words does not exceed 30000.

Output

In the first and the only line of the output file WIR.OUT one should find a word:

  • TAK - if an infinite, safe sequence of zeroes and ones exists.
  • NIE - otherwise.

Example

For the input file WIR.IN:

3
01 
11 
00000

the correct result is the output file WIR.OUT:

NIE



Print friendly version