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

const ll q = 29;
const ll mod = 1000000007;
ll p, H1, H2;
char c;
int n;

int main ()
	{
	scanf ("%d ",&n);
	p=1;
	while (true)
		{
		c = getchar_unlocked();
		if (c<'a' || c>'z')
			break;
		c -= ('a'-1);
		(H1+=(p*c))%=mod;
		((H2*=q)+=c)%=mod;
		(p*=q)%=mod;
		}
	printf ("%s\n",H1==H2 ? "TAK" : "NIE");
	return 0;
	}