1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <bits/stdc++.h>
using namespace std;
#define rep(a,b) for(a=0;a<(b);++a) 
const int M=1e2+7;
string l[M]; 
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,i;
	int ja,jb,jc,da,db,dc,ta,tb,tc,ca,cb,cc,pa,pb,pc;
	cin >> n;
    rep(i,n) cin >> l[i];
    rep(i,n){
    	if(l[i]=="1A") ++ja;
    	else if(l[i]=="1B") ++jb;
    	else if(l[i]=="1C") ++jc;
    	else if(l[i]=="2A") ++da;
        else if(l[i]=="2B") ++db;
        else if(l[i]=="2C") ++dc;
        else if(l[i]=="3A") ++ta;
        else if(l[i]=="3B") ++tb;
        else if(l[i]=="3C") ++tc;
        else if(l[i]=="4A") ++ca;
        else if(l[i]=="4B") ++cb;
        else if(l[i]=="4C") ++cc;
        else if(l[i]=="5A") ++pa;
        else if(l[i]=="5B") ++pb;
        else if(l[i]=="5C") ++pc;
    }
    if(ja>=1&&jb>=1&&jc>=1&&da>=1&&db>=1&&dc>=1&&ta>=1&&tb>=1&&tc>=1&&ca>=1&&cb>=1&&cc>=1&&pa>=2&&pb>=2&&pc>=2)
    {
        cout << "TAK";
    } 
    else cout << "NIE";
    return 0;
}