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
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    int n; cin>>n;
    int result=18;
    vector <vector <int>>Tab (3, vector <int> (5));
    for(int i=0; i<3; ++i){
        for(int j=0; j<5; ++j){
            Tab[i][j]=0;
        }
    }
    for(int i=0; i<n; ++i){
        string a; cin>>a;
        if(a[0]=='5'){
            if(Tab[a[1]-65][4]<=1){++Tab[a[1]-65][4]; --result;}}
        else if(!Tab[a[1]-'A'][a[0]-'0'-1]){++Tab[a[1]-'A'][a[0]-'0'-1]; --result;}
        if(!result) break;
    }
    if(!result) cout<<"TAK\n";
    else cout<<"NIE\n";
    return 0;
}