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;

string C[]={"1","2","3","4","5"};
string L[]={"A", "B", "C"};

int main(){
	
	map<string,int> zadania;
	int t;
	string zad="";;
	cin>>t;

	if(t<18){
		cout<<"NIE";
		return 0;
	}

	while(t--){
		cin>>zad;
		zadania[zad]++;
	}	
	//for(auto a:zadania) cout<<a.first<<" "<<a.second<<"\n";
	
	for(int i=0;i<4;i++){
		for(int j=0;j<3;j++){
			zad=C[i]+L[j];
			if(zadania[zad]<1){
				cout<<"NIE\n";
				return 0;
			}
			zad="";
		}
	}
	for(int i=4;i<5;i++){
		for(int j=0;j<3;j++){
			zad=C[i]+L[j];
			if(zadania[zad]<2){
				cout<<"NIE\n";
				return 0;
			}
			zad="";
		}
	}
	cout<<"TAK\n";

	return 0;
}