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
#include <bits/stdc++.h>

using namespace std;

int n, countEx, it;
string ans = "NIE\n";
string shortPossibleEx[15] = {"1A","2A","3A","4A","5A","1B","2B","3B","4B","5B","1C","2C","3C","4C","5C"};
int shortPossibleExInt[1500];

int main()
{
    cin>>n;
    vector<string> shortEx(n+1);
    for (int i = 0; i<n; i++)
    {
        cin>>shortEx[i];
    }
    sort(shortEx.begin(), shortEx.end());
    for (int i = 0; i<n; i++)
    {
        for (int j = 0; j<n; j++)
        {
            if (shortEx[j]==shortPossibleEx[it])
            {
                shortPossibleExInt[(int)shortEx[j][1]+(int)shortEx[j][0]]++;
                it++;
            }
        }
    }
    for (int i = 1; i<1500; i++)
    {
        if (shortPossibleExInt[i]==1)
        {
            countEx++;
        }
    }
    if (countEx==15)
    {
        ans="TAK\n";
    }
    cout<<ans;
    return 0;
}