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
#include <cstdio>

int N = 0;

int zadania[3][7];

int main(){
	scanf("%d\n", &N);
	while(N--){
		char type;
		int round;
		scanf("%d%c", &round, &type);
		switch(type){
			case 'A':
				zadania[0][round]++;
				break;
			case 'B':
				zadania[1][round]++;
				break;
			case 'C':
				zadania[2][round]++;
				break;
		}
	}
	
	for(int i = 0; i < 3; i++){
		for(int j = 1; j < 5; ++j){
			if(zadania[i][j] < 1){
				puts("NIE\n");
				return 0;
			}
		}
		if(zadania[i][5] < 2){
			puts("NIE\n");
			return 0;
		}
	}
	puts("TAK\n");
	return 0;
}