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
53
54
55
#include <cstdio>
#include <cassert>
#include <set>
#include <vector>
#include <map>

int skipWhites() {
    int a = getchar_unlocked();
    while (a == ' ' || a == '\n') {
        a = getchar_unlocked();
    }
    return a;
}

int readInt() {
    int result = 0;
    int a = skipWhites();
    while (a != ' ' && a != '\n' && a != EOF) {
        result = result * 10;
        a-= '0';
        result+=a;
        a = getchar_unlocked();
    }
    if (result < 0) {
        return -1;
    }
    return result;
}

int main() {
//    ios base::sync with stdio(false);
//    cin.tie(nullptr);
    int n = readInt();

    int A[18] = {0};

    int total = 0;
    for (int i = 0; i < n; i++) {
        int a = skipWhites();
        int b = getchar_unlocked();
        int id = (a- '0') * 3 + b - 'A';
        if (A[id] == 0) {
            total++;
            A[id]++;
        } else if (15 <= id && A[id] == 1) {
            total++;
            A[id]++;
        }
    }
    if (total == 18) {
        printf("TAK");
    } else {
        printf("NIE");
    }
}