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

using namespace std;

int main()
{
    int a, w = 0, x;
    string b;
    cin >> a;
    int tab[18];
    for(int i = 0; i < 18; i ++)
    {
        tab[i] = 0;
    }
    if(a < 18)
    {
        cout << "NIE" << endl;
    }else{
        for(int i = 0; i < a; i ++)
        {
            cin >> b;
            x = (int) b[0] - 48;
            x = 3*x;
            x = x + (int) b[1] - 65;
            if(x > 14)
            {
                if(tab[x] < 2)
                {
                    tab[x] ++;
                    w ++;
                }
            }else{
                if(tab[x] == 0)
                {
                    tab[x] = 1;
                    w++;
                }
            }
        }

        if(w == 18)
        {
            cout << "TAK" << endl;
        }else{
            cout << "NIE" << endl;
        }
    }
    return 0;
}