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
39
40
41
42
43
#include <ctime>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;
const int MAXN = 500;
const int MAXM = 500;

#define FOR(i, n) for(int i = 0, __n = (n); i < __n; i++)




int main() {
  ios_base::sync_with_stdio(0);
  int n;
  char buf[10];
  int tot[5*3];
  FOR (i, 5*3) tot[i] = 0;
  cin >> n;

  FOR (i, n) {
    cin >> buf;
    int idx = (buf[0] - '1') * 3 + (buf[1] - 'A');
    tot[idx]++;
  }

  bool ok = true;
  FOR (i, ('5'-'1')) {
    FOR (j, ('C' - 'A' + 1)) {
      if (tot[i*3 + j] < 1) ok = false;
    }
  }

  FOR (j, ('C' - 'A' + 1)) {
    if (tot[4*3 + j] < 2) ok = false;
  }
  if (ok) cout << "TAK" << endl;
  else cout << "NIE" << endl;
  return 0;
}