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

int main() {
    int32_t n;
    std::cin >> n;

    int32_t taskSlots[5][3] = {};
    
    for (int32_t i = 0; i < n; ++i) {
        std::string task;
        std::cin >> task;

        int32_t round = task[0] - '1';
        char division = task[1] - 'A';

        taskSlots[round][division] += 1;
    }

    bool ok = true;
    for (int32_t division = 0; division < 3; ++division) {
        ok &= taskSlots[0][division] >= 1;
        ok &= taskSlots[1][division] >= 1;
        ok &= taskSlots[2][division] >= 1;
        ok &= taskSlots[3][division] >= 1;
        ok &= taskSlots[4][division] >= 2;
    }
    std::cout << (ok ? "TAK" : "NIE") << "\n";
}