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
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A[5] = {1, 1, 1, 1, 2};
  int B[5] = {1, 1, 1, 1, 2};
  int C[5] = {1, 1, 1, 1, 2};
  int n;
  cin >> n;
  for(int i = 0;i < n;i++){
    int k;
    char typ;
    cin >> k >> typ;
    if(typ == 'A')
      A[k - 1]--;
    if(typ == 'B')
      B[k - 1]--;
    if(typ == 'C')
      C[k - 1]--;
  }
  for(int i = 0;i < 5;i++)
    if(A[i] > 0 || B[i] > 0 || C[i] > 0){
      cout << "NIE";
      return 0;
    }
  cout << "TAK";
}