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

unordered_map<string, int> cnt;

int main() {
  int n;
  cin >> n;
  while (n--) {
    string s;
    cin >> s;
    cnt[s]++;
  }
  for (char r = '1'; r <= '5'; r++) {
    for (char d = 'A'; d <= 'C'; d++) {
      if (cnt[string(1, r) + string(1, d)] < 1 + (r == '5')) {
        cout << "NIE\n";
        return 0;
      }
    }
  }
  cout << "TAK\n";
}