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
#include <iostream>
#include <set>
#include <utility>
#include <string>
#include <map>

using namespace std;

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

    set<string> positionsTaken;
    int lastCount[3]{0, 0, 0};

    while (n--)
    {
        string s;
        cin >> s;

        positionsTaken.insert(s);
        if (s[0] == '5')
            lastCount[s[1]-'A']++;
    }

    if (positionsTaken.size() == 15
            && lastCount[0]>=2 && lastCount[1]>=2 && lastCount[2]>=2)
        cout << "TAK";
    else
        cout << "NIE";

    cout << '\n';
}