1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <unordered_map>

int main() {
    std::ios_base::sync_with_stdio(0);
    std::unordered_map<std::string, int> count;

    for (const std::string& s : {"A","B","C"})
        for (const std::string& r : {"1","2","3","4","5","5"})
            count[r+s]++;
    int n;
    std::cin >> n;
    while (n--) {
        std::string x;
        std::cin >> x;
        count[x]--;
    }
    bool ok = true;
    for (const auto& x : count) ok &= x.second <= 0;
    std::cout << (ok ? "TAK" : "NIE") << std::endl;
    return 0;
}