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

using namespace std;

int n,a;
char b;
int tab[5][3];
int main() {
    tab[4][0] = -1;
    tab[4][1] = -1;
    tab[4][2] = -1;

    scanf("%d",&n);
    for(int i = 0; i<n; ++i){
        scanf("%d%c",&a,&b);
        ++tab[a-1][int(b)-'A'];
    }
    bool poss = true;
    for(int i = 0; i<5; ++i){
        for(int j = 0; j<3; ++j){
            if(tab[i][j] <= 0) poss = false;
        }
    }
    poss ? printf("TAK") : printf("NIE");
    return 0;
}