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
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
using namespace std;

int n;
int tab[5][3];
bool wyn = 1;

int main () {
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) {
		int a;
		char c;
		scanf("%d %c", &a, &c);
		tab[a-1][c- 'A']++;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			if (tab[i][j] < 1) wyn = 0;
		} 
	}
	for (int i = 0; i < 3; i++) {
		if (tab[4][i] < 2) wyn = 0;
	}
	if (wyn) printf("TAK"); else printf("NIE");
}