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
#include<bits/stdc++.h>
using namespace std;
map<string,int> s;
string x[] = {"A","B","C"};
string d[] = {"1","2","3","4"};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n; cin >> n;
    for(int i = 0; i < n; i++) {
        string h; cin >> h;
        s[h]++;
    }
    for(auto a : x) {
        for(auto b : d) {
            if(s[b+a] < 1) {
                cout <<"NIE";
                return 0;
            }
        }
    }
    if(s["5B"] < 2 ||s["5A"] < 2 ||s["5C"] < 2 ) {
        cout << "NIE";
    }
    else cout << "TAK";
}