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
/*
 * author: pavveu
*/

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

#define FOR(iter, val) for(int iter = 0; iter < (val); iter++)
#define all(x) begin(x), end(x)

void go() {
	int n; cin >> n;
	vector<int> cnt(0x100, 0);
	FOR(i, n) {
		int temp;
		cin >> hex >> temp;
		cnt[temp]++;
	}
	bool ok = true;
	for (int i = 1; i <= 5; i++) {
		int needed = (i == 5 ? 2 : 1 );
		for ( int j = 0xa; j <= 0xc; j++ )  
			if ( cnt[ i * 16 + j ] < needed ) ok = false;
	}
	
	if ( ok ) cout << "TAK\n";
	else cout << "NIE\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	go();
	return 0;
}