1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <cstdio>

int p[5][3];

int main ()
{
  int n;
  scanf ("%i", &n);
  while (n--)
  {
    char a, b;
    scanf (" %c%c", &a, &b);
    if ('1'<=a && a<='5' && 'A'<=b && b<='C') p[a-'1'][b-'A']++;
  }
  for (int a=0; a<5; a++)
  for (int b=0; b<3; b++)
  if (p[a][b] < (a==4? 2: 1))
  {
    puts ("NIE");
    return 0;
  }
  puts ("TAK");
  return 0;
}