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;

const int N = 109;
int n, ile[N], a;
string pom;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >>n;

    for(int i=1; i <= n; i++) {
        cin >>pom;
        a = pom[0] - 48 + 5*(pom[1]-65);
        //cout <<a<<" ";
        ile[a]++;
    }

    for(int i=1; i <= 15; i++) {
        if( ile[i] == 0 ){
            cout <<"NIE\n";
            return 0;
        }
    }

    if( ile[5] == 1 || ile[10] == 1 || ile[15] == 1 ) cout <<"NIE\n";
    else cout <<"TAK\n";
    
    return 0;
}