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

int main() {
    std::unordered_map<std::string, int> occurrences;
    char chars[] = {'A', 'B', 'C'};

    for (auto character : chars) {
        for (int i = 1; i <= 5; i++) {
            occurrences[std::to_string(i) + character] = 0;
        }
    }

    int numberOfIdeas;
    std::cin >> numberOfIdeas;
    std::string exercise;

    for (int i = 0; i < numberOfIdeas; i++) {
        std::cin >> exercise;
        occurrences[exercise]++;
    }

    bool isValid = true;
    for (const auto& key : occurrences) {
        if (key.second == 0 || ((key.first == "5A" || key.first == "5B" || key.first == "5C") && key.second < 2)) {
            isValid = false;
        }
    }

    if (isValid) {
        std::cout << "TAK";
    } else {
        std::cout << "NIE";
    }

    return 0;
}