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
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long lld;
typedef double lf;
typedef long double llf;
typedef pair<int,int> pii;
typedef pair<lld,lld> pll;
#define For(i,s,a) for(int i = (int)s; i < (int)a; ++i)
#define rpt(s, it) for(auto it = s.begin(); it != s.end(); ++it)
#define brpt(s, it) for(auto it = s.rend(); it != s.rbegin(); --it)
#define sz size()
#define pb push_back
#define eb emplace_back
#define ff first
#define dd second
#define mp make_pair
 
template<typename Ta, typename Tb>
ostream & operator <<(ostream & os, pair<Ta, Tb> x){
return os << x.ff << " " << x.dd;
}
 
/*#define ONLINE_JUDGE
#ifdef ONLINE_JUDGE
	freopen("cottages.in" , "r" , stdin);
	freopen("cottages.out" , "w" , stdout);
#endif
*/

int ile[5][3];

int32_t main(void){
	int n;
	scanf("%d", &n);
	while(n--){
		int day;
		char div;
		scanf("%d%c", &day, &div);
		++ile[day - 1][div - 'A'];
	}
	bool ok = 1;
	For(i, 0, 5)
	For(j, 0, 3)
	ok &= ile[i][j] > 0;
	For(j, 0, 3)
	ok &= ile[4][j] > 1;
	puts(ok ? "TAK" : "NIE");
}
/*
19
3B 4B 5B 4C 5C 3C 1A 5A 5C 3A 5A 2C 1B 2A 5B 5C 2B 1C 4A
*/
/*
20
2B 4B 4C 5A 5C 5C 4A 1B 3A 4A 2A 3B 1B 1C 1A 5A 2C 1B 5B 3C
*/