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
#include <algorithm>
#include <cstdio>
#include <vector>
#include <set>

using namespace std;

int main()
{
	long n, r, a[18]={0};
	char d;
	scanf("%ld", &n);
	for (long i = 0; i < n; ++i)
	{
		scanf("%ld%c", &r, &d);
		a[r * 3 + d - 'A']++;
	}

	for (long i = 3; i < 18; ++i)
	{
		if (a[i] <= (i / 15))
		{
			printf("%s", "NIE");
			return 0;
		}
	}
	printf("%s", "TAK");
	return 0;
}