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
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long int;
const ll BASE[] = {47, 29, 37};
const ll MOD[] = {10000000000000949, 10000000000000069, 10000000000000597};
ll BT[] = {1,1,1};
ll H[2][3];
int c;
int main() {
	c = getchar();
	while (c < 'a' || c > 'z')
		c = getchar();
	while (c >= 'a' && c <= 'z') {
		c -= 'a';
		for (int i = 0; i < 1; i++) {
			H[0][i] *= BASE[i];
			H[0][i] %= MOD[i];
			H[0][i] += c;
			if (H[0][i] >= MOD[i])
				H[0][i] -= MOD[i];

			H[1][i] += BT[i] * c;
			H[1][i] %= MOD[i];

			BT[i] *= BASE[i];
			BT[i] %= MOD[i];
		}
		c = getchar();
	}
	for (int i = 0; i < 1; i++) {
		if (H[0][i] != H[1][i]) {
			printf("NIE\n");
			return 0;
		}
	}
	printf("TAK\n");
}