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

int n;
int zad[10][10];
char rround, ddiv;

int main() {
  scanf("%d", &n);
  while(n--){
    scanf(" %c%c", &rround, &ddiv);
    zad[rround - '1'][ddiv - 'A']++;
  }

  for(ddiv='A'; ddiv <= 'C'; ddiv++){
    for(rround=1; rround<5; rround++){
      if (!zad[rround-1][ddiv-'A']){
        printf("NIE\n");
        return 0;
      }
    }

    if (zad[5-1][ddiv-'A'] < 2){
      printf("NIE\n");
      return 0;
    }
  }
  printf("TAK\n");
}