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

using namespace std;

int main(){

int T[15];

for (int i=0;i<12;++i) T[i]=1;
for (int i=12;i<15;++i) T[i]=2;

string s;
int n,i,ok=0;
cin>>n;

while(n--){
  cin>>s;
  i = (s[0] - '0') * 3 - 3 + (s[1] - 'A');
  T[i]--;
  if (T[i]==0) ok++;
}

if (ok==15) cout<<"TAK\n";
else cout<<"NIE\n";

return 0;
}