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 <cstdio>
#include <cstdlib>
#include <cassert>

int counts[5][3] = {0};

int main() {
    int n;
    scanf("%d", &n);

    while (n --> 0) {
        char text[16];
        scanf("%s", text);

        assert(text[0] >= '1' && text[0] <= '5');
        assert(text[1] >= 'A' && text[1] <= 'C');

        counts[text[0] - '1'][text[1] - 'A']++;
    }

    for (int i = 0; i < 4; i++) {
        if (counts[i][0] < 1 || counts[i][1] < 1 || counts[i][2] < 1) {
            puts("NIE");
            return 0;
        }
    }
    if (counts[4][0] < 2 || counts[4][1] < 2 || counts[4][2] < 2) {
        puts("NIE");
        return 0;
    }

    puts("TAK");
    return 0;
}