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

using namespace std;

int cnt[10][10];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	while(n--){
		string s;
		cin >> s;
		int cyfra = s[0] - '1'; /// 0..4
		int znak = s[1] - 'A'; /// 0..2
		cnt[znak][cyfra]++;
	}
	bool nie = 0;
	for(int i = 0; i <= 2; i++){
		for(int j = 0; j <= 3; j++)
			if(cnt[i][j] == 0)
				nie = 1;
		if(cnt[i][4] < 2)
			nie = 1;
	}
	if(nie)
		cout << "NIE";
	else
		cout << "TAK";
	return 0;
}