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
#include <iostream>

using namespace std;

int main() {
    int t; 
    cin >> t;
    int array[16];
    for ( int i = 0; i < 16; i++)
        array[i] = 0;
    int counter = 0, x;
    while ( t-- ) {
        string s;
        cin >> s;
        if ( s[1] == 'A')
            x = s[0] - '0';
        else if ( s[1] == 'B' )
            x = ( s[0] - '0' ) + 5;
        else 
            x = ( s[0] - '0' ) + 10 ;
        array[x]++;
        if ( array[x] == 1 && x !=5 && x != 10 && x != 15)
            counter++;
        if ( (x == 5 || x == 10 || x == 15) && array[x] == 2 )
            counter++;
    }
    if ( counter == 15 )
        cout << "TAK" << endl;
    else
        cout << "NIE" << endl;
    return 0;
}