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

bool check(vector<vector<int>>& fq) {
  for (int i = 0; i <= 3; ++i) {
    for (auto x : fq[i]) {
      if (x < 1)
        return false;
    }
  }

  return (fq[4][0] > 1) && (fq[4][1] > 1) && (fq[4][2] > 1);
}

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

  int n; cin >> n;
  vector<vector<int>> fq(5, vector<int>(3));
  while (n--) {
    string s; cin >> s;
    ++fq[s[0]-'1'][s[1]-'A'];
  }
  if (check(fq)) cout << "TAK";
  else cout << "NIE";
}