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
35
36
37
38
39
40
#include<cstdio>

int cnt[15];

bool chck() {
    for (int i = 0; i < 15; ++i)
        if (cnt[i] < 1)
            return false;
    return true;
}

int main() {
    int n;
    scanf("%i", &n);
    
    
    for (int i = 0; i < 15; ++i)
        cnt[i] = 0;
    
    cnt[12] -= 1;
    cnt[13] -= 1;
    cnt[14] -= 1;
    
    for (int i = 0; i < n; ++i) {
        char txt[10];
        scanf("%s", txt);
        
        int rnd = txt[0] - '1';
        int div = txt[1] - 'A';
        
        cnt[3*rnd + div] += 1;
    }
    
    if(chck())
        printf("TAK\n");
    else
        printf("NIE\n");
    
    return 0;
}