1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <bits/stdc++.h>
using namespace std;

map<char,map<int,int>> tasks;
bool check(char type) {
    for(int i=0;i<5;i++) {
        if ( i+1 == 5 ) if ( tasks[type][i+1] < 2 ) return false;
        if ( tasks[type][i+1] < 1 ) return false;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    while( n --> 0 ) {
        string str;
        cin >> str;     
        tasks[ str[1] ][ int(str[0]-48) ] += 1;
    }
    bool OK=check('A') && check('B') && check('C');
    if ( OK ) cout << "TAK";
    else cout << "NIE";
}