1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <cstdio>

int count[5][3];

int wanted[] = {1, 1, 1, 1, 2};

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    char a, b;
    scanf(" %c%c", &a, &b);
    ++count[a - '1'][b - 'A'];
  }
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 5; ++j) {
      if (count[j][i] < wanted[j]) {
        puts("NIE");
        return 0;
      }
    }
  }
  puts("TAK");
}