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
52
53
#include <iostream>

#define N 300

using namespace std;

int expected[6][N];

void setup_expected() {
  for (int group = 'A'; group <= 'C'; group++) {
    expected[1][group] = 1;
    expected[2][group] = 1;
    expected[3][group] = 1;
    expected[4][group] = 1;
    expected[5][group] = 2;
  }
}

bool check_expected() {
  for (int round = 1; round <= 5; round++) {
    for (int group = 'A'; group <= 'C'; group++) {
      if (expected[round][group] > 0) {
        return false;
      }
    }
  }

  return true;
}

int main() {
  setup_expected();

  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    int round;
    char group;

    cin >> round >> group;

    expected[round][group]--;
  }

  if (check_expected()) {
    cout << "TAK";
  } else {
    cout << "NIE";
  }

  return 0;
}