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
#include <bits/stdc++.h>
using namespace std;

int a[666][7];
int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        char division, order_of_business;
        cin >> order_of_business >> division;
        order_of_business -= '0';
        a[division][order_of_business]++;
    }

    for (char i = 'A'; i <= 'C'; i++){
        for (char j = 1; j <= 5; j++){
            if (a[i][j] < 1){
                cout << "NIE\n";
                return 0;
            }
        }
    }
    if (a['A'][5] >= 2 && a['B'][5] >= 2 && a['C'][5] >= 2){
        cout << "TAK\n";
    } else cout << "NIE\n";



}