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
38
39
40
41
42
#include<bits/stdc++.h>

#define luk(n,m) for(int i=n; i<m; ++i)
#define maxn 310
#define pb(n) push_back(n)
#define mp make_pair
#define inf 1000000000
#define mod 1000000007
#define mod1 1000696969
#define ll long long
#define ff first.first
#define fs first.second


using namespace std;



int main()
{
	int n;
	ll hasz=0, hasz1=0, hasz2=0, hasz3=0;
	ll p=29,p1=29;
	char c=' ';
	scanf("%d", &n);
	while(c<'a'||c>'z')
	c=getchar_unlocked();
	while(c<='z'&&c>='a')
	{
		hasz=(hasz+(c-'a')*p)%mod;
		hasz1=(hasz1+(c-'a')*p1)%mod1;
		p=(p*29)%mod;
		p1=(p1*29)%mod1;
		hasz2=(((29*hasz2)%mod)+(((c-'a')*29)%mod));
		hasz3=(((29*hasz3)%mod1)+(((c-'a')*29)%mod1));
		c=getchar_unlocked();
	}
	if(hasz==hasz2&&hasz1==hasz3)
	printf("TAK");
	else
	printf("NIE");
}