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
#include <bits/stdc++.h>

using namespace std;

long long c, u, v, l=2137, p=1, m=1000696969;

int main()
{
	scanf("%lld", &c);
	c=getchar_unlocked();
	while(c<=96||c>=123)
	{
		c=getchar_unlocked();
	}
	while(c>96&&c<123)
	{
		c-=97;
		u=(u+c*p)%m;
		p=(p*l)%m;
		v=(v*l+c)%m;
		c=getchar_unlocked();
	}
	if(u!=v)
	{
		printf("NIE");
	}
	else
	{
		printf("TAK");
	}
	return 0;
}