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

using namespace std;
using ll = long long;
using llu = unsigned long long;

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

  int n;
  cin >> n;
  vector<array<int, 3>> x(5);
  for (int i = 0; i < n; i++) {
    char a,b;
    cin >> a >> b;
    x[a-'1'][b-'A']++;
  }
  bool good = true;
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++)
      if (x[i][j] < 1) good = false;
  }
  for (int j = 0; j < 3; j++)
    if (x[4][j] < 2) good = false;
  if (good) cout << "TAK\n";
  else cout << "NIE\n";

  return 0;
}