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
#include <bits/stdc++.h>
#define lld long long int
#define MOD1 2846409647
#define MOD2 2846409641
using namespace std;
int xd;
lld s1;
lld s2;
lld s3;
lld s4;
lld pot1=1;
lld pot2=1;
char a;
int main()
{
	while(1)
	{
		a = getchar();
        if (a <48 or a>57) { break; }
	}
	while(1)
	{
		a = getchar();
        if (a <97 or a>122) { break; }
		s1=(s1+(((int)a-96)*pot1))%MOD1;
		s2=((s2*33)+(int)a-96)%MOD1;
		s3=(s3+(((int)a-96)*pot2))%MOD2;
		s4=((s4*33)+(int)a-96)%MOD2;
		pot1=(pot1*33)%MOD1;
		pot2=(pot2*33)%MOD2;
	}
	
	if(s1==s2 and s3==s4)
	{
		puts("TAK");
	}
	else
	{
		puts("NIE");
	}
}