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
// wyb | Solution by Mikołaj Zabłocki (Dominik Korsa)
// https://sio2.mimuw.edu.pl/c/pa-2020-1/p/wyb/

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;

  vector<vector<int>> table(5, vector<int>(3, 0));
  int successCount = 0;

  for (int i = 0; i < n; i++) {
    string in;
    cin >> in;
    int digit = in[0] - '1'; // '3' becomes 2
    int letterIndex = in[1] - 'A'; // 'B' becomes 1

    table[digit][letterIndex]++;
    if (digit == 4) { if (table[digit][letterIndex] == 2) successCount++; }
    else if (table[digit][letterIndex] == 1) successCount++;

    cerr << in << ": " << digit << " " << letterIndex << endl;
  }

  cerr << successCount << endl;
  if (successCount == 15) cout << "TAK";
  else cout << "NIE";

  return 0;
}