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
/* -----------------------
Autor: Tomasz Boguslawski
-------------------------- */
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<fstream>
#include<iomanip>
#include<string>
#include<sstream>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include <fstream>
#include<math.h>

#define FOR(x, b, e) for(long x = b; x <= (e); x++)
#define FORD(x, b, e) for(long x = b; x >= (e); x--)
#define VAR(v, n) __typeof(n) v = (n)
#define ALL(c) (c).begin(), (c).end()
#define FOREACH(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define DEBUG if (debug)
#define MIN(a,b) ((a>b)?b:a)
#define MAX(a,b) ((a>b)?a:b)
#define LL long long

#define DEBUGMODE false

using namespace std;

/// MAIN
int main(int argc, char* argv[])
{
    // magic formula, which makes streams work faster:
	ios_base::sync_with_stdio(0);

	// handle input data:
	int n; string s;
	int t[6][4];
	FOR(x,0,5)FOR(y,0,3) t[x][y]=0;
	cin >> n;
	FOR(i,1,n) {
	    cin >> s;
	    if (s.length()<2) { cout << "NIE\n"; return 0; }
	    int x=(int)s[0] - 48; int y = (int)s[1]-64;
	    t[x][y]++;
	}
	bool ok=true;
	FOR(x,1,4)FOR(y,1,3) if (t[x][y]==0) ok=false;
	FOR(y,1,3) if (t[5][y]<2) ok=false;
	if (ok) cout << "TAK\n"; else cout << "NIE\n";
    return 0;
};