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
#include<bits/stdc++.h>
using namespace std;
int N;
int tab[6][5];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>N;
    int zad=18;
    for(int i=1;i<=N;i++){
        char c,z;
        cin>>c>>z;
        if((c-'1'+1)<5 && tab[(c-'1'+1)][z-'A']==0){
            tab[(c-'1'+1)][z-'A']=1;
            zad--;
        }
        else if((c-'1'+1)==5 && tab[(c-'1'+1)][z-'A']<2){
            tab[(c-'1'+1)][z-'A']++;
            zad--;
        }
    }
    if(zad==0) cout<<"TAK";
    else cout<<"NIE";
    return 0; 
}