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
#include<bits/stdc++.h>
using namespace std;
int n,T[100];
char c1,c2;
int main()
{
    cin >> n;
    for (int i = 1 ; i <= n ; i++)
    {
        cin>> c1 >> c2;
        int jed = c1 - '0';
        int dwa;
        if(c2 =='A')
            dwa = 1;
        else if(c2 == 'B')
            dwa = 2;
        else
            dwa = 3;
        T[jed+dwa*10]++;
    }
    int dasie =1;
    for (int i = 1 ; i <= 5 ; i++)
    {
        if(i != 5)
            for (int k = 1 ; k <= 3 ; k++)
            {
                if(T[k*10+i] == 0)
                    dasie = 0;
            }
        if(T[15] < 2 || T[25] < 2 || T[35] < 2)
            dasie = 0;
    }
    if(dasie == 0)
        cout <<"NIE";
    else
        cout<<"TAK";
}