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

int main() {
    int n;
    std::map<std::string, int> tasks;
    std::cin >> n;
    while (n--) {
       std::string ts;
       std::cin >> ts;
       ++tasks[ts];
    }
    bool good = true;
    for (char c = 'A'; c <= 'C'; ++c) {
        for (char i = '1'; i <= '4'; ++i) {
            std::string ts;
            ts += i;
            ts += c;
            if (tasks[ts] < 1) good = false;
        }
        std::string ts = "5";
        ts += c;
        if (tasks[ts] < 2) good = false;
    }
    std::cout << (good ? "TAK" : "NIE") << std::endl;
    return false;

}