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
#include <iostream>
#include <string>
using namespace std;

int main()
{
    //int n;
    //cin >> n;

    string str;
    getline(std::cin, str);
    getline(std::cin, str);

    int count[100] = {};
    for (int i = 0; i < str.size(); i += 3)
    {
        char number = str[i] - '1';
        char letter = str[i+1] - 'A';
        int key = number *10 + letter;
        count[key]++;
    }

    for (int i = 0; i < 5; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            int key = i * 10 + j;
            int expected = i == 4 ? 2 : 1;
            if (count[key] < expected)
            {
                std::cout << "NIE\n";
                return 0;
            }

        }
    }

    std::cout << "TAK\n";
}