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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>
#include <string>

using namespace std;

int str2int(string str){
    int pomoc[5][3];
    pomoc[0][0] = 0;
    pomoc[0][1] = 1;
    pomoc[0][2] = 2;
    pomoc[1][0] = 2;
    pomoc[1][1] = 3;
    pomoc[1][2] = 4;
    pomoc[2][0] = 4;
    pomoc[2][1] = 5;
    pomoc[2][2] = 6;
    pomoc[3][0] = 6;
    pomoc[3][1] = 7;
    pomoc[3][2] = 8;
    pomoc[4][0] = 8;
    pomoc[4][1] = 9;
    pomoc[4][2] = 10;
    int a = str[0] - '0';
    int b = str[1] - 'A';
    return a + pomoc[a-1][b];
    
}

int main()
{
    int n;
    cin >> n;
    string str[n];
    for(int i = 0; i < n; i++) cin >> str[i];
    int tab[15];
    for(int i = 0; i < 15; i++) tab[i] = 0;
    for(int i = 0; i < n; i++){
        tab[str2int(str[i])-1] = tab[str2int(str[i])-1] + 1;
    }
    int j = 0;
    while(j < 12){
        if(tab[j] >= 1){
            j++;
        } 
        else{
            break;
        }
    }
    if(j == 12){
        while(j < 15){
            if(tab[j] >= 2){
                j++;
            }else{
                break;
            }
        }
    }
    
    if(j == 15) cout << "TAK";
    else cout << "NIE";

    return 0;
}