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

using namespace std;

int toInt(string s){
    return (s[0]-'1')*3 + (s[1] - 'A');
}

int main(){
    int n;
    cin>>n;
    vector<int> cnt(15, 0);
    for(int i = 0; i < n; i++){
        string str; cin>>str;
        cnt[toInt(str)]++;
    }
    bool result = true;
    for(int i = 0; i < 15; i++){
        if(cnt[i] == 0)result = false;
    }
    if(result){
        if(cnt[toInt("5A")] >= 2 && cnt[toInt("5B")] >= 2 && cnt[toInt("5C")] >= 2){
            cout<<"TAK\n";
        }else{
            cout<<"NIE\n";
        }
    }else{
        cout<<"NIE\n";
    }
    return 0;
}