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

using namespace std;
int N;
int x, y, c = 1;
int tab[6][3];
bool ans = 1;
string word;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    for(int i=0; i^N; ++i){
        cin >> word;
        x = word[0]-48;
        y = word[1]-65;
        tab[x][y]++;
    }
    for(int i=1; i<=5; ++i){
        if(i==5) c=2;
        for(int z=0; z^3; ++z){
            if(tab[i][z]<c) ans=0;
        }
    }
    if(ans) cout << "TAK\n";
    else cout << "NIE\n";
    return 0;
}