Viruses

No attempts yetTime limit3sMemory limit512 MB

Problem

The Binary Viruses Investigation Committee discovered that certain sequences of zeroes and ones are virus codes. The committee has isolated the set of all virus codes. A sequence of zeroes and ones is called safe if none of its segments (a segment is a sequence of consecutive elements) equals a virus code. The committee wants to determine whether an infinite, safe sequence of zeroes and ones exists.

Write a program that:

  • reads the virus codes from standard input,
  • determines whether an infinite, safe sequence of zeroes and ones exists,
  • writes the result to standard output.

Input

The first line contains a single integer nn, the number of virus codes. Each of the next nn lines contains one non-empty word made of 0s and 1s - a virus code. The total length of all words does not exceed 3000030000.

Output

Print a single word on the only line of standard output:

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

Hint

For the set of codes {011,11,00000}\{011, 11, 00000\}, one example of a safe infinite sequence is 010101010101\ldots. For the set of codes {01,11,00000}\{01, 11, 00000\}, no safe infinite sequence of zeroes and ones exists.