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
42
43
44
45
46
47
48
49
50
51
#include <cstdio>
    #include <iostream>
    #include <stdio.h>
    using namespace std;


  int main() {

    int count[5][3];
    for (int round = 0; round < 5; round++) {
      for (int division = 0; division < 3; division++) {
        count[round][division] = 0;
      }
    }

    int n = 0;

    int c = getchar();
    while (c > 32) {
      int digit = c - '0';
      n = n * 10 + digit;
      c = getchar();
    }

    for (int i = 0; i < n; i++) {
      do {
        c = getchar();
      } while (c <= 32);
      int round = c - '1';
      int division = getchar() - 'A';

      count[round][division]++;
    }

    for (int round = 0; round < 4; round++) {
      for (int division = 0; division < 3; division++) {
        if (count[round][division] < 1) {
          printf("%s", "NIE");
          return 0;
        }
      }
    }
    for (int division = 0; division < 3; division++) {
      if (count[4][division] < 2) {
        printf("%s", "NIE");
        return 0;
      }
    }
    printf("%s", "TAK");
    return 0;
  }