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

using namespace std;

map<string, int> ideas;
int n;

int main() {
  cin >> n;

  for (int i = 1; i <= 5; i++) {
    ideas[to_string(i) + "A"] = 0;
    ideas[to_string(i) + "B"] = 0;
    ideas[to_string(i) + "C"] = 0;
  }

  string temp;
  for (int i = 0; i < n; i++) {
    cin >> temp;

    ideas[temp]++;
  }

  bool possible = true;

  for (const auto& id : ideas) {
    if (((id.first == "5A" || id.first == "5B" || id.first == "5C") && id.second < 2) || id.second < 1) possible = false;
  }

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