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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*************************************************************************
 *                                                                       *
 *                   Potyczki Algorytmiczne 2020                         *
 *                                                                       *
 *   Zadanie:              Wybor zadan                                   *
 *   Autor:                Lukasz Sztukiewicz                            *
 *   Szkola:               VIII Liceum im. Adama Mickiewicza w Poznaniu  *
 *   Wersja:               0.1                                           *
 *************************************************************************/
#include<cstdio>
#include<cstdlib>

using namespace std;

const char *format1c_ = "%c ";
const char *format1c = "%c";
const char *format1d = "%d";

int ans = 0;
int n, u;
char digit, word;
int is[60];
int num[] = {11,12,13,21,22,23,31,32,33,41,42,43,51,52,53};

int main()
{
    scanf(format1d, &n);
    while(n--)
    {
        scanf(format1c, &digit);
        scanf(format1c_, &word);
        u = (digit-48)*10 + word-64;
        is[u]++;
    }
    for(int i = 0; i<15;i++)
    {
        if(is[num[i]] < 1)
        {
            printf("NIE");
            return 0;
        }

        if(i > 11 && is[num[i]]< 2)
        {
            printf("NIE");
            return 0;
        }

    }
    printf("TAK");
    return 0;
}