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
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

const LL MOD = 1e9 + 7, base = 29;

int main() {
	int n;
	scanf("%d", &n);
	char c;
	LL h1 = 0, h2 = 0;
	LL b1 = 1;
	while((c = getchar()) != EOF) {
		h1 += (LL)(c - 'a' + 1) * b1;
		h2 *= base;
		h2 += (LL)(c - 'a' + 1);
		h2 %= MOD;
		h1 %= MOD;
		b1 *= base;
		b1 %= MOD;
	}
	if(h1 == h2)
		puts("TAK");
	else puts("NIE");
}