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
#include <iostream>

using namespace std;

int main(){
	int n,j=0,tmp=0,tmp2;
	cin>>n;
	char tab[n*2];
	int out[15];
	for(int i=0;i<n*2;i++){
		cin>>tab[i];
	}
	for(int i=0;i<n*2;i+=2){
		if(tab[i+1]=='A')tmp2=0;
		if(tab[i+1]=='B')tmp2=5;
		if(tab[i+1]=='C')tmp2=10;
		tmp=tab[i]+tmp2-'0';
		out[tmp]++;
	}
	for(int i=0;i<15;i++){
		if(i%5==0&&out[i]<2){
				cout<<"NIE";
				return 0;}
		if(out[i]<1&&i%5!=0){
			cout<<"NIE";
			return 0;
			}
		}
	
	cout<<"TAK";
	return 0;
}