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 <stdio.h>
#include <string.h>

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

    int remA[] = {1, 1, 1, 1, 2};
    int remB[] = {1, 1, 1, 1, 2};
    int remC[] = {1, 1, 1, 1, 2};
    int *rem[] = {remA, remB, remC};
    int totalRem = 3 * 6;

    while (n > 0)
    {
        char buf[100];
        scanf("%s", buf);
        if (strlen(buf) > 0)
        {
            n--;
            int &r = rem[buf[1] - 'A'][buf[0] - '1'];
            if (r > 0)
            {
                r--;
                totalRem--;
            }
        }
    }

    printf(totalRem == 0 ? "TAK\n" : "NIE\n");

    return 0;
}