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>
using namespace std;

void counting(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    pair<string, short> table[15] = {
        pair<string, int>("1A",0),
        pair<string, int>("1B",0),
        pair<string, int>("1C",0),
        pair<string, int>("2A",0),
        pair<string, int>("2B",0),
        pair<string, int>("2C",0),
        pair<string, int>("3A",0),
        pair<string, int>("3B",0),
        pair<string, int>("3C",0),
        pair<string, int>("4A",0),
        pair<string, int>("4B",0),
        pair<string, int>("4C",0),
        pair<string, int>("5A",0),
        pair<string, int>("5B",0),
        pair<string, int>("5C",0)
    };
    int n;
    string world;
    cin >> n;

    for(int i=0; i<n; ++i){
        cin >> world;
        for(int j=0; j<15; ++j){
            if(world == table[j].first){
                ++table[j].second;
                //cout << table[j].first << " " << table[j].second << '\n';
                break;
            }
        }
        if(table[0].second >= 1 && table[1].second >= 1 && table[2].second >= 1 && table[3].second >= 1 && table[4].second >= 1 && table[5].second >= 1 && table[6].second >= 1 && table[7].second >= 1 && table[8].second >= 1 && table[9].second >= 1 && table[10].second >= 1 && table[11].second >= 1 && table[12].second >= 2 && table[13].second >= 2 && table[14].second >= 2){
            cout << "TAK";
            return;
        }
    }

    cout << "NIE";
}

int main(){
    counting();
    return 0;
}