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
#include <bits/stdc++.h>
using namespace std;

void Solve() {
  int n;
  cin >> n;

  map<string, int> counts;
  for (int i = 0; i < n; ++i) {
    string problem;
    cin >> problem;
    ++counts[problem];
  }

  for (int r = 1; r <= 5; ++r) {
    for (auto division: {"A", "B", "C"}) {
      string type = to_string(r) + division;
      int requires = r == 5 ? 2 : 1;
      if (counts[type] < requires) {
        cout << "NIE\n";
        return;
      }
    }
  }

  cout << "TAK\n";
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  Solve();
}