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
#include<bits/stdc++.h>
using namespace std;
int x;
char c;
long long pa, pb, ka, kb, pot1=1, pot2=1;
const long long M1=10e7, M2=10e9, p=211;;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >>x;
	while (cin>>c)
	{
		if (c>96 && c<123)
		{
			pa=(pa*p+c-97)%M1;
			pb=(pb*p+c-97)%M2;
			ka=(ka+pot1*(c-97))%M1;
			kb=(kb+pot2*(c-97))%M2;
			pot1=(pot1*p)%M1;
			pot2=(pot2*p)%M2;
		}
	}
	if (pa==ka && pb==kb)cout<<"TAK\n";
	else
	cout<<"NIE\n";
	
}