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 <bits/stdc++.h>

int main() {
    int n;
    std::vector<std::string> v;
    std::cin >> n;
    for (int i = 1; i <= n; i++) {
        std::string s; std::cin >> s;
        v.push_back(s);
    }
    for (char i = '1'; i <= '4'; i++) {
        for (char c = 'A'; c <= 'C'; c++) {
            std::string tmp = "";
            bool found = false;
            tmp += i;
            tmp += c;
            for (auto x: v) 
                if (x == tmp)
                    found = true;
            if (!found) {
                std::cout << "NIE\n";
                return 0;
            }
        }
    }
    for (char c = 'A'; c <= 'C'; c++) {
        int cnt = 0;
        std::string tmp = "5";
        tmp += c;
        for (auto x: v)
            if (x == tmp)
                cnt++;
        if (cnt < 2) {
            std::cout << "NIE\n";
            return 0;
        }
    }
    std::cout << "TAK\n";
}