#include <stdio.h>
struct tree
{
tree *fail, *next[2];
int flag, visit;
};
tree arr[30005];
int indexx;
tree *root, *p;
void newn()
{
arr[indexx].fail = NULL;
arr[indexx].flag = 0;
arr[indexx].visit = 0;
for(int i = 0; i < 2; i ++) arr[indexx].next[i] = 0;
}
void init()
{
indexx = 0;
newn();
root = &arr[indexx ++];
}
void insert(char ch[])
{
int t, i = 0;
p = root;
while(ch[i])
{
t = ch[i] - '0';
if(p->next[t] == 0)
{
newn();
p->next[t] = &arr[indexx ++];
}
p = p->next[t];
i ++;
}
p->flag = 1;
}
tree *que[30005];
bool check(tree *q)
{
while(q != root)
{
if(q->flag) return true;
q = q->fail;
}
return false;
}
void get_fail()
{
int close = -1, open = 0;
p = root; p->fail = root;
que[0] = p;
while(close < open)
{
p = que[++close];
for(int i = 0; i < 2; i ++)
{
int danger;
if(danger = check(p)) p->flag = 1;
if(p->next[i] == 0)
{
if(p == root) p->next[i] = root;
else p->next[i] = p->fail->next[i];
}
else
{
if(p == root) p->next[i]->fail = root;
else p->next[i]->fail = p->fail->next[i];
que[++open] = p->next[i];
}
}
}
}
int n;
char str[30005];
bool ok;
void solve(tree *q)
{
for(int i = 0; i < 2; i ++)
{
if(q->next[i]->visit)
{
ok = true;
return;
}
if(q->next[i]->flag) continue;
q->next[i]->flag = 1;
q->next[i]->visit = 1;
solve(q->next[i]);
if(ok) return;
q->next[i]->visit = 0;
}
}
int main()
{
while(scanf("%d",&n) != EOF)
{
init();
for(int i = 0; i < n; i ++)
{
scanf("%s", str);
insert(str);
}
get_fail();
root->visit = true;
ok = false;
solve(root);
if(ok) puts("TAK");
else puts("NIE");
}
return 0;
}