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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <bits/stdc++.h>

using namespace std;

#define MAX_N
#define MOD 1000000007
#define INF INT_MAX
#define pb push_back
#define mp(x, y) make_pair((x), (y))
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<bool, int> pbi;

//  ----------
//  SOLUTION
//  ----------

inline int index(int root, int val) {
	// printf("%X\n", val - root - 0xA);
	return val - root - 0xA;
}

int main() {
	int n;
	scanf("%d", &n);

	int kub[6][3];
	for (int i = 0; i < 6; i++) {
		for (int j = 0; j < 3; j++) {
			kub[i][j] = 0;
		}
	}

	while (n--) {
		int val;
		scanf("%x", &val);

		if (val > 0x50) kub[5][index(0x50, val)]++;
		else if (val > 0x40) kub[4][index(0x40, val)]++;
		else if (val > 0x30) kub[3][index(0x30, val)]++;
		else if (val > 0x20) kub[2][index(0x20, val)]++;
		else kub[1][index(0x10, val)]++;
	}


	for (int i = 1; i <= 5; i++) {
		for (int j = 0; j < 3; j++) {
			if (i == 5) {
				if (kub[i][j] < 2) {
					printf("NIE\n");
					return 0;
				}
			} else if (kub[i][j] == 0) {
				printf("NIE\n");
				return 0;
			}
		}
	}

	printf("TAK\n");
	return 0;
}