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
52
53
54
#include <stdio.h>
#include <map>
#include <string>
#include <iostream>

using namespace std;

int main(){
    map<string, int> possible = {
            {"1A", 1},
            {"1B", 1},
            {"1C", 1},
            {"2A", 1},
            {"2B", 1},
            {"2C", 1},
            {"3A", 1},
            {"3B", 1},
            {"3C", 1},
            {"4A", 1},
            {"4B", 1},
            {"4C", 1},
            {"5A", 2},
            {"5B", 2},
            {"5C", 2},
    };

    long long int number;
    char idea [2];
    string ideas;
    scanf("%lld\n", &number);

    getline (cin, ideas);
    for (long long int idx=0; idx< number; ++idx) {
        string check = ideas.substr (3*idx,2);
        std::map<string, int>::iterator checker =  possible.find(check);

        if (checker == possible.end()) {
            continue;
        }
        checker->second -= 1;
    }

    for ( map<string, int>::iterator it = possible.begin(); it != possible.end(); ++it )
    {

        if (it->second > 0) {
            printf("NIE\n");
            return 0;
        }
    }

    printf("TAK\n");
    return 0;
}