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

using namespace std;

char t[10];
int k;
map<string, int> tasks;


int main() {
  scanf("%d", &k);
  for (int i = 0; i < k; ++i) {
    scanf("%s", t);
    ++tasks[t];
  }
  bool ok = true;
  for (int round = 1; round <= 5; ++round) {
    for (char div = 'A'; div <='C'; ++div) {
      sprintf(t, "%d%c", round, div);
      int expected = round == 5 ? 2 : 1;
      if (tasks[t] < expected) {
        ok = false;
        break;
      }

    }
  }
  printf("%s\n", ok ? "TAK" : "NIE");
  return 0;
}