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>
using namespace std;

const long long prime1 = 2137;
const long long prime2 = 6029;
const long long mod1 = 1e9+7;
int n;
long long normal1, normal2, reverse1, reverse2, primePower1 = 1, primePower2 = 1;
char c;
string s;


int main() {
	scanf("%d", &n);
	scanf("%c", &c);
	while(c < 'a' || c > 'z')scanf("%c", &c);
	while(c >= 'a' && c <= 'z') {
		normal1 += c * primePower1;
		primePower1 *= prime1;
		if(primePower1 > mod1) primePower1 %= mod1;
		if(normal1 > mod1) normal1 %= mod1;
		
		normal2 += c * primePower2;
		primePower2 *= prime2;
		if(primePower2 > mod1) primePower2 %= mod1;
		if(normal2 > mod1) normal2 %= mod1;
		
		
		reverse1 *= prime1;
		reverse1 += c;
		if(reverse1 > mod1) reverse1 %= mod1;
		
		reverse2 *= prime2;
		reverse2 += c;
		if(reverse2 > mod1) reverse2 %= mod1;
		scanf("%c", &c);
	}
	if(normal1 == reverse1 && normal2 == reverse2) printf("TAK\n");
	else printf("NIE\n");
	//cout << s << endl;
	return 0;
}