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
#include <iostream>
using namespace std;
int A[10],B[10],C[10];
bool czy_odp(){
	for(int i=1;i<=6;i++){
		if(A[i]==0||B[i]==0||C[i]==0){
			return 0;
		}
	}
	return 1;
}
int main() {
	int n;
	string lol;
	cin >> n;
	if(n<18){
		cout << "NIE";
		return 0;
	}
	for(int i=1;i<=n;i++){
		cin >> lol;
		if(lol[0]=='5'){
			if(lol[1]=='A'){
				if(A[5]==1) A[6]=1;
				else A[5]=1;
			}
			else if(lol[1]=='B'){
				if(B[5]==1) B[6]=1;
				else B[5]=1;
			}
			else if(lol[1]=='C'){
				if(C[5]==1) C[6]=1;
				else C[5]=1;
			}
		}
		else{
			if(lol[1]=='A') A[(lol[0]-48)]=1;
			else if(lol[1]=='B') B[(lol[0]-'0')]=1;
			else if(lol[1]=='C') C[(lol[0]-'0')]=1;
		}
	}
	if(czy_odp()==0) cout<<"NIE";
	else cout<< "TAK";
	return 0;
}