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
#include <bits/stdc++.h>
#define rep(n) for(int i = 0;i<n;i++)
#define MAXN 1000*1000+1
 
typedef unsigned long long ull;
 
using namespace std;


int n;
string s;
set<string> st;
multiset<string> div5;
int main()
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	cin>>n;
	rep(n)
		{
			cin>>s;
			if(s != "5A" && s != "5B" && s != "5C")
				st.insert(s);
			else
				div5.insert(s);		
		}
	
	if(st.size() == 12 && div5.count("5A") >= 2 && div5.count("5B") >= 2 && div5.count("5C") >= 2)
		cout<<"TAK"<<endl;
	else
		cout<<"NIE"<<endl;
		
	return 0;
}