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
#include<bits/stdc++.h>
#define mod 1000000007
#define p 31
using namespace std;
int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	//cout.tie(NULL);
	long long n,x,pot,h1,h2;
	//char a;
	cin>>n;
	h1=0;
	h2=0;
	pot=1;
	x=getchar();
	while(true)
	{
		//cout<<a<<"\n";
		x=getchar();
		if(!(('a'<=x)&&(x<='z')))
			break;
		x-='a';
		h1=(h1+((pot*x)%mod))%mod;
		pot=(pot*p)%mod;
		h2=(((h2*p)%mod)+x)%mod;
	}
	//cout<<h1<<" "<<h2<<"\n";
	if(h1==h2)
		cout<<"TAK";
	else
		cout<<"NIE";
	return 0;
}