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

using namespace std;

int main() {
    short in_count;
    std::string in, result;
    std::string q[18] = {"1A", "1B", "1C", "2A", "2B", "2C", "3A", "3B", "3C",
                         "4A", "4B", "4C", "5A", "5B", "5C", "5A", "5B", "5C"};
    cin >> in_count;
    for (int i = 0; i < in_count; ++i) {
        cin >> in;
        result += in;
    }

    for (auto & i : q) {
        size_t found = result.find(i);
        if(found == std::string::npos) {
            cout << "NIE";
            return 0;
        } else {
            result.erase(found, i.size());
        }
    }
    cout << "TAK";
    return 0;
}