#include<bits/stdc++.h>
using namespace std;
#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair<int,int>
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int mod=1e9+7;
const int maxn=3e4+10;
const int maxm=5e5+10;
const ll INF=1e18;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){
if(y==0) return x;
return gcd(y,x%y);
}
int n,tr[maxn][2],mark[maxn],fail[maxn],cnt=0;
string s[3000];
vector<int> g[maxn];///建fail树
void insert(int x){
int cur=0;
for(int i=0;i<s[x].size();i++){
int tmp=s[x][i]-'0';
if(!tr[cur][tmp]) tr[cur][tmp]=++cnt;
cur=tr[cur][tmp];
}
mark[cur]=1;
}
void OP(int x,int y,int z){
fail[x]=y;
///mark[x]=mark[y];不知道为什么这样不可以。。。。
g[y].push_back(x);
}
void build(){
queue<int> q;
rep(i,0,2) if(tr[0][i]){
q.push(tr[0][i]);
OP(tr[0][i],0,i);
}
while(!q.empty()){
int tp=q.front();q.pop();
rep(i,0,2){
if(tr[tp][i]){
OP(tr[tp][i],tr[fail[tp]][i],i);
q.push(tr[tp][i]);
}else tr[tp][i]=tr[fail[tp]][i];
}
}
}
void dfs(int x,int y){
mark[x]=y||mark[x];
for(auto v:g[x]) dfs(v,mark[x]);
}
int vis[maxn],flag=0;
void judge(int x){
if(vis[x]) flag=1;
if(flag) return ;
if(mark[x]) return ;
vis[x]=1;
rep(i,0,2) judge(tr[x][i]);
vis[x]=0;
}
int main(){
ios::sync_with_stdio(false);/*
freopen("d://in.txt","r",stdin);
freopen("d://out.txt","w",stdout);*/
int n;cin>>n;
rep(i,0,n){
cin>>s[i];
insert(i);
}
build(),dfs(0,0);
judge(0);
if(flag) cout<<"TAK\n";
else cout<<"NIE\n";
return 0;
}