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
#include <iostream>
#include <map>
#include <string> 

using namespace std;

typedef map<string, int> KV;

bool check(KV &threshold, KV &tasks) {
    for(auto &kv: threshold)
        if(tasks[kv.first] < kv.second) return false;

    return true;
}

int main() {
    int n;
    string s;
    KV threshold, tasks;
    
    for(int i=1; i<=5; ++i)
        for(char c='A'; c<='C'; ++c) {
            string key = to_string(i)+c;
            if(i==5) threshold[key]=2;
            else threshold[key]=1;
        }
        
    cin >> n;
    while(n--) {
        cin >> s;
        ++tasks[s];
    }
    
    cout << (check(threshold, tasks) ? "TAK" : "NIE") << endl;

    return 0;
}