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
#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const ll MOD = 1000000000000000003,P1=29,P2=31; 
char a;
ll pref1,suf1,pref2,suf2,p1=1,p2=1;
int n;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	while(cin>>a){
		pref1+=((ll)a-96)*p1;
		pref2+=((ll)a-96)*p2;
		p1*=P1;
		p2*=P2;
		suf1*=P1;
		suf2*=P2;
		suf1+=(ll)a-96;
		suf2+=(ll)a-96;
	}
	if(pref1==suf1 && pref2==suf2)cout<<"TAK";
	else cout<<"NIE";
}