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
43
44
45
46
47
48
49
#include<bits/stdc++.h>
using namespace std;

const int p=29;
const int mod=(1<<31)-1;

long long xd;
long long qp(long long a, long long b){
	xd=1;
	if(b<=0) return 1;
	while(b){
		if(b&1) xd*=a;
		a*=a;
		xd%=mod;
		a%=mod;
		b>>=1;
	}
	return xd;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	char a;
	long long h1=0,h2=0,p2=1,o;
	int n;
	cin>>n;
	
	o=qp(p,mod-2);
	
	n=0;
	while(cin>>a){
		n++;
		h1+=a-'a'+1;
		h1*=p;
		h1%=mod;
		
		p2*=p;
		p2%=mod;
		h2+=p2*(a-'a'+1);
		h2%=mod;
	}
	
	if(h1==h2) cout<<"TAK\n";
	else cout<<"NIE\n";
	return 0;
}