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
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <unordered_map>
using namespace std;




int main() {
    int N;

    unordered_map<string, int> reqTasks;
    for(char r = '1'; r <= '5'; ++r) {
        for(char c = 'A'; c <= 'C'; ++c) {
            string task = "";
            task += r;
            task += c;
            reqTasks[task] = 1;
        }
    }
    for(char c = 'A'; c <= 'C'; ++c) {
        string task = "5";
        task += c;
        reqTasks[task] += 1;
    }

    cin >> N;
    for(int i = 0; i < N; ++i) {
        string task;
        cin >> task;
        --reqTasks[task];
    }

    for(char r = '1'; r <= '5'; ++r) {
        for(char c = 'A'; c <= 'C'; ++c) {
            string task = "";
            task += r;
            task += c;
            if (reqTasks[task] > 0) {
                // cout << "[TASK = " << task << "] ";
                cout << "NIE";
                return 0;
            }
        }
    }

    cout << "TAK";
    return 0;
}