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
#include <cstdio>
using namespace std;

int N;
char S[3];
int sm, st[5][3];

int main() {
	sm = 18;
	for (int i = 0; i < 5; ++i) {
		for (int j = 0; j < 3; ++j) {
			st[i][j] = 1 + (i/4);
		}
	}

	scanf("%d", &N);

	for (int i = 0; i < N; ++i) {
		scanf("%s", S);
		if (st[S[0] - '1'][S[1] - 'A']-- > 0) {
			sm--;
		}
	}

	printf("%s\n", sm ? "NIE" : "TAK");
	return 0;
}