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
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef pair <ii,int> iii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 1000;

char t[N];
int n, val, i, mn, hash1, hash2;

int main() {
scanf("%d\n", &n);
hash1 = 17;
mn = 1;
hash2 = 0;
while (fgets(t, sizeof(t), stdin)) {
	for (i=0;i<N;i++) {
		if (t[i] < 'a' || t[i] > 'z') break;
		val = int(t[i]);
		hash1 = hash1 * 31 + val;
		hash2 = hash2 + mn * val;
		mn = mn * 31;
	}
}
hash2 += mn * 17;
if (hash1 == hash2) printf("TAK\n"); else printf("NIE\n");
return 0;
}