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
#include <vector>
#include <string>
#include <iostream>
#include <unordered_map>
#include <algorithm>

using namespace std; 
 
int main()
{
    std::iostream::sync_with_stdio(false);
    
    vector<string> vect;
    string lul[3] = {"A","B","C"};
    int n;
    std::cin >> n;
    
    if (n < 18)
    {
        cout << "NIE";
        return 0;
    }
 
    while (n--)
    {
        std::string s;
        std::cin >> s;
        vect.push_back(s);
    }
 
    sort(vect.begin(), vect.end());
    
    for (int i = 1; i < 6; i++) {
        for (int j = 0; j < 3; j++) {
            string item = to_string(i) + lul[j];
            
            if (i == 5 && count(vect.begin(), vect.end(), item) < 2)
            {
                std::cout << "NIE";
                return 0;
            }
            else if (find(vect.begin(), vect.end(), item) != vect.end() == false)
            {
                std::cout << "NIE";
                return 0;
            }
        }
    }
    
 
    std::cout << "TAK";
    return 0;
}