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
37
38
39
40
41
42
43
44
45
46
47
48
#include <bits/stdc++.h> 
using namespace std;
int taba[7];
int tabb[7];
int tabc[7];
 int main() 
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;cin>>n;
if(n<18) 
{
	cout<<"NIE";return 0;
}
string s;
int ile=0;
for(int i=0;i<n;i++)
{
	cin>>s;
	if(s[1]=='A')
	{
		taba[s[0]-'0']++;
//		cout<<s[0]-'0'<<" "<<taba[s[0]-'0']<<endl;
		if(s[0]-'0'==5 && taba[s[0]-'0']==2) ile++;
		else if(s[0]-'0'<5 && taba[s[0]-'0']==1) ile++;
	}
	else if(s[1]=='B')
	{
		tabb[s[0]-'0']++;
//		cout<<s[0]-'0'<<" "<<tabb[s[0]-'0']<<endl;
		if(s[0]-'0'==5 && tabb[s[0]-'0']==2) ile++;
		else if(s[0]-'0'<5 && tabb[s[0]-'0']==1) ile++;
	}
	else if(s[1]=='C')
	{
		tabc[s[0]-'0']++;
		
//		cout<<s[0]-'0'<<" "<<tabc[s[0]-'0']<<endl;
		if(s[0]-'0'==5 && tabc[s[0]-'0']==2) ile++;
		else if(s[0]-'0'<5 && tabc[s[0]-'0']==1) ile++;
	}
}
//cout<<ile<<endl;
if(ile>=15) cout<<"TAK";
else cout<<"NIE";
return 0;
}