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
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n; cin >> n;
    
    if (n < 18) {
        cout << "NIE" << endl;
    } else {
        vector <string> full(15);
        for (int i=0; i < 5; i++) {
            for (int j=0; j < 3; j++) {
                full[3*i+j] = to_string(i+1);
                switch (j) {
                    case 0: full[3*i+j] += "A"; break;
                    case 1: full[3*i+j] += "B"; break;
                    case 2: full[3*i+j] += "C"; break;
                }
            }
        }
        full.push_back("5A");
        full.push_back("5B");
        full.push_back("5C");
        
        int work = 0;
        
        for (int i=0; i < n; i++) {
            string input; cin >> input;
            for (int j=0; j < full.size(); j++) {
                if (full[j] == input) {work++; full[j] = "0"; break;}
            }
        }
        if (work == 18) cout << "TAK" << endl;
        else cout <<"NIE" << endl;
    }
    return 0;
}