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

int main() {
    int result[255] = {0};
    unsigned int n;
    unsigned int x;
    int count = 0;
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> std::hex >> x;
        result[x] += 1;
        int expected = x < 0x5A ? 1 : 2;
        if (result[x] == expected) {
            count++;
        }
    }
    std::cout << (count == 15 ? "TAK" : "NIE") << std::endl;
    return 0;
}