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
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int n, tab[15];
char a, b;
int main() {

    cin >> n;

    while (n--) {
        cin >> a >> b;
        int val = (a - '1')*3 + (b - 'A');
        tab[val]++;
    }

    for (int i = 0; i < 15; i++) {
        if (tab[i] < 1) {
            cout << "NIE" << endl;
            return 0;
        }
        if (tab[i] < 2  && i >= 12) {
            cout << "NIE" << endl;
            return 0;
        }
    }
    cout << "TAK" << endl;

    return 0;
}