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

short tab[5][3];   //global makes it automaticly zero initialized

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::string input, answear = "TAK";
    short n;
    std::cin >> n;
    for(short i = 0; i < n; i++) {
        std::cin >> input;
        short n = input[0] - '1', m = input[1] - 'A';
        ++tab[n][m];
    }
    for(short i = 0; i < 4; i++) {
        for(short j = 0; j < 3; j++)
            if(tab[i][j] < 1) {
                answear = "NIE";
            }
    }
    for(short i = 0; i < 3; i++) {
        if(tab[4][i] < 2)
            answear = "NIE";
    }
    std::cout << answear << std::flush;
    return 0;
}