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
#include <bits/stdc++.h>
using namespace std;

int main(){
int n;
cin >> n;
string a[n];
map <string, int> m;
for (int i=0; i<n;i++){
    cin >> a[i];
    m[a[i]]+=1;
}
bool czek=1;
for (char i='1'; i<='5';i++){
    for (char x='A';x<='C';x++){
        string tmp;
        tmp+=i;
        tmp+=x;
        //cout << tmp<<" "<<m[tmp]<<endl;
        if ((i!='5' && m[tmp]<1) || (i=='5' && m[tmp]<2)){
            czek=0;
        }
    }
}
if (czek==1){
    cout << "TAK"<<endl;
}else{
    cout << "NIE"<<endl;
}

}