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
#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>

int main()
{
  std::ios::sync_with_stdio(false);

  int n;
  std::unordered_map<std::string, int> counts;

  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    std::string x;
    std::cin >> x;
    counts[x]++;
  }

  std::vector<std::string> check = { "1A", "1B", "1C", "2A", "2B",
                                     "2C", "3A", "3B", "3C", "4A",
                                     "4B", "4C", "5A", "5B", "5C" };

  bool is_correct = std::all_of(
    check.cbegin(), check.cend(), [&](auto &&x) { return counts[x] > 0; });
  is_correct =
    is_correct && counts["5A"] >= 2 && counts["5B"] >= 2 && counts["5C"] >= 2;

  std::cout << (is_correct ? "TAK" : "NIE") << std::endl;
  return 0;
}