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

using namespace std;

bool** ideas;

bool isGood() {
    for (short i = 0; i < 6; i++) {
        for (short j = 0; j < 3; j++) {
            if (!ideas[i][j])
                return false;
        }
    }
    return true;
}

int main()
{
    int n;
    cin >> n;
    string input="";
    ideas = new bool*[6];
    for (short i = 0; i < 6; i++) {
        ideas[i] = new bool[3];
        ideas[i][0] = false;
        ideas[i][1] = false;
        ideas[i][2] = false;
    }
    for (short i = 0; i < n; i++) {
        cin >> input;
        if (input[0] < 53)
            ideas[input[0] - 49][input[1] - 65] = true;
        else if (!ideas[4][input[1] - 65])
            ideas[4][input[1] - 65] = true;
        else
            ideas[5][input[1] - 65] = true;
    }

    if (isGood()) {
        cout << "TAK" << endl;
    }
    else {
        cout << "NIE" << endl;
    }

    return 0;
}