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
49
50
51
#include <bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
#define MOD 1000000007
#define INF 1000000000
#define pb push_back
#define endl "\n"
const long double pi = 3.1415926536;
using namespace std;

void solve(){
    multiset <string> se = {"1A", "1B", "1C", "2A", "2B", "2C", "3A", "3B", "3C", "4A", "4B", "4C", "5A", "5B", "5C"};
    int n;
    bool met_5a = false, met_5b = false, met_5c = false;
    string s;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> s;
        if (s == "5A" && !met_5a){
            met_5a = true;
            continue;
        }
        if (s == "5B" && !met_5b){
            met_5b = true;
            continue;
        }
        if (s == "5C" && !met_5c){
            met_5c = true;
            continue;
        }
        se.erase(s);
    }
    if (!se.empty()){
        cout << "NIE\n";
    }
    else{
        cout << "TAK\n";
    }
}

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    //cin >> t;
    while (t--){
        solve();
    }
    return 0;
}