#P2444. [POI 2000] 病毒

[POI 2000] 病毒

Description

The Binary Virus Review Committee has recently discovered the following pattern: certain specific binary strings are virus code. If a piece of code contains no occurrence of any virus code, we call this code safe. Now that the committee has identified all virus code segments, determine whether there exists an infinitely long safe binary code.

Example:

For instance, if {011,11,00000}\{011, 11, 00000\} are virus code segments, then one possible infinitely long safe code is 010101010101 \ldots. If {01,11,000000}\{01, 11, 000000\} are virus code segments, then there does not exist an infinitely long safe code.

Given all virus code segments, determine whether an infinitely long safe code exists.

Input Format

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

Each of the next nn lines contains a nonempty binary string, representing a virus code segment.

Output Format

If an infinitely long safe code exists, output TAK; otherwise, output NIE.

3
01 
11 
00000

NIE

Hint

1n20001 \leq n \leq 2000, and the total length of all virus code segments does not exceed 3×1043 \times 10^4.

Translated by ChatGPT 5