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
32
33
34
35
36
37
38
39
40
41
#include <bits/stdc++.h>
using namespace std;

int solve() {
  int a;
  cin >> a;
  unordered_map<string, int> counter;
  for(int i=0; i < a; ++i) {
    string s;
    char c1, c2;
    cin >> c1;
    cin >> c2;
    s.push_back(c1);
    s.push_back(c2);
    counter[s] += 1;
  }
  for(char c ='A'; c <= 'C'; ++c) {
    for(char i='1'; i <= '4'; ++i) {
      string s;
      s.push_back(i);
      s.push_back(c);
      if (counter[s] == 0) {
        cout << "NIE" << endl;
        return 0;
      }
    }
    string s2;
    s2.push_back('5');
    s2.push_back(c);
    if (counter[s2] < 2) {
      cout << "NIE" << endl;
      return 0;
    }
  }
  cout << "TAK" << endl;
  return 0;
}

int main() {
  solve();
}