1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#include <cstdio>
using namespace std;

#define FOR(i,a,b) for(int (i)=(int)(a); (i)!=(int)(b); ++(i))

char S[10];
int n, X[5][3];
int main() {
    FOR(i,0,5) FOR(j,0,3) X[i][j] = 0;

    scanf("%d", &n);
    FOR(i,0,n) {
        scanf("%s", S);
        ++X[S[0] - '1'][S[1] - 'A'];
    }

    bool ok = true;
    FOR(i,0,4) FOR(j,0,3) if (X[i][j] < 1) ok = false;
    FOR(j,0,3) if (X[4][j] < 2) ok = false;
    if (ok) printf("TAK\n"); else printf("NIE\n");
}