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
#include <cstdio>
#include <map>

using namespace std;

int main() {
  int n; scanf("%d", &n);
  
  map<pair<int, int>, int> tasks;
  for (int i=0; i<n; ++i) {
    char s[256]; scanf("%s ", &s);
    tasks[make_pair(s[0] - '1', s[1] - 'A')]++;
  }

  for (int i=0; i<4; ++i) {
    for (int j=0; j<3; ++j) {
      if (tasks[make_pair(i, j)] < 1) {
        printf("NIE\n");
        return 0;
      }
    }
  }
  for (int j=0; j<3; ++j) {
    if (tasks[make_pair(4, j)] < 2) {
      printf("NIE\n");
      return 0;
    }
  }

  printf("TAK\n");
  return 0;
}