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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    const short POMYSLY=15;
    short n,i;
    short LiPomyslow[POMYSLY];
    for(i=0; i<POMYSLY; i++) LiPomyslow[i]=0;
    string pomysl;
    cin>>n;
    while(n--){
        cin>>pomysl;
        LiPomyslow[(pomysl[0]-49)*3+(pomysl[1]-65)]++;
    }
    for(i=0; i<POMYSLY-3; i++){
        if(!LiPomyslow[i]){
            cout<<"NIE\n";
            return 0;
        }
    }
    for(; i<POMYSLY; i++){
        if(LiPomyslow[i]<2){
            cout<<"NIE\n";
            return 0;
        }
    }
    cout<<"TAK\n";
    return 0;
}