#Q64. 「一本通 2.4 练习 5」病毒

「一本通 2.4 练习 5」病毒

Description

Original Source: POI 2000

The Binary Virus Review Committee recently discovered the following pattern: certain specific binary strings are virus codes. If a segment of code does not contain any virus code segment, it is considered safe. Now that the committee has identified all virus code segments, the question is: does there exist an infinitely long safe binary code?

Example: For instance, if {011,11,00000}\{011, 11, 00000\} are the virus code segments, then a possible infinitely long safe code could be 010101010101\cdots . However, if {01,11,000000}\{01, 11, 000000\} are the virus code segments, then no infinitely long safe code exists.

Write a program that reads the virus codes and determines whether an infinitely long safe code exists, then outputs the result.

Input Format

The first line contains an integer nn, indicating the number of virus code segments;

The following nn lines each contain a non-empty 0101 string—each representing a virus code segment.

Output Format

The first line outputs a single word. If such a code exists, output TAK; otherwise, output NIE.

Sample 1

3
01
11
00000

NIE

Data Range and Hint

For all data, the total length of all virus code segments does not exceed 3×1043\times 10^4.