1326. Viruses

单点时限: 2.0 sec

内存限制: 256 MB

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:

1.reads virus codes,

2.determines, whether an infinite, safe sequence of zeroes and ones exists

3.writes the result.

输入格式

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.

输出格式

In the first and the only line of the output one should find a word:

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

NIE - otherwise.

样例

Input
3
01
11
00000
Output
NIE

7 人解决,10 人已尝试。

13 份提交通过,共有 35 份提交。

6.6 EMB 奖励。

创建: 16 年,8 月前.

修改: 6 年,7 月前.

最后提交: 11 年,1 月前.

来源: POI 2000 I Stage

题目标签