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
#include<bits/stdc++.h>
using namespace std;

const int K = 1e5 + 23;
const int N = 1e6 + 23;

vector<int> p;
int n, k, A, B;


int main()
{   
    ios_base::sync_with_stdio(false);

    multiset<string> s;
    for (char r = '1'; r <= '5'; ++r) {
        for (char lv = 'A'; lv <= 'C'; ++lv) {
            int repeat = r == '5' ? 2 : 1;
            for (int _ = 1; _ <= repeat; ++_) {
                string tmp;
                tmp += r;
                tmp += lv;
                s.insert(tmp);
            }
        }
    }
    
    int n;
    cin >> n;
    
    while (n--) {
        string tmp;
        cin >> tmp;
        
        auto p = s.find(tmp);
        if (p != s.end()) { s.erase(p); }
    }
    
    cout << (s.empty() ? "TAK" : "NIE") << '\n';
}