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
#include<iostream>

using namespace std;

int main(void)
{
	char c;
	long long a='a'-1, x1=1, x2=1, x3=1, m=10e9+7, h1=0, r1=0, h2=0, r2=0, h3=0, r3=0, n;
	cin>>n;
	while(cin>>c)
	{
		h1=(h1+(c-a)*x1)%m;
		r1=(r1*31+c-a)%m;
		x1=(x1*31)%m;
		h2=(h2+(c-a)*x2)%m;
		r2=(r2*97+c-a)%m;
		x2=(x2*97)%m;	
		h3=(h3+(c-a)*x3)%m;
		r3=(r3*193+c-a)%m;
		x3=(x3*193)%m;	
	
	}
	if(h1==r1 && h2==r2 && h3==r3)
		cout<<"TAK\n";
	else
		cout<<"NIE\n";
}