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
#include <bits/stdc++.h>
using namespace std;
int t[50],n, dz;
char c;
int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; ++i)
    {
        scanf("%d", &dz);
        scanf("%c", &c);        
     //   cout<<dz<<" "<<c<<" "<<c-'A'<<" "<<" "<<dz + (5*(c-'A'))<<endl;
        dz = dz + (5*(c-'A'));

        t[dz]++;
    }
    for(int i = 1; i < 16; ++i)
    {
        if(i%5 && t[i] < 1)
        {
            printf("NIE");
            return 0;
        }
        else if(i%5 == 0 && t[i] < 2)
        {
            printf("NIE");
            return 0;
        }
    }
    printf("TAK");
}