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
#include <iostream>
using namespace std;

int fillation[6][3] = {
    0, 0, 0,
    -1, -1, -1,
    -1, -1, -1,
    -1, -1, -1,
    -1, -1, -1,
    -2, -2, -2
};

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i){
        char x,y;
        cin >> x >> y;
        int day = x-48;
        int level = y-65; // A -> 0 | B -> 1 | C -> 2
        fillation[day][level] += 1;
    }

    bool error = false;

    for (int i = 0; i < 6; ++i){
        for (int j = 0; j < 3; ++j){
            if (fillation[i][j] < 0) {
                error = true;
            }
        }
    }

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