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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <bits/stdc++.h>

using namespace std;

#define LL long long
#define ULL unsigned long long

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	if(n>0)
	{
		ULL hasp = 0;
		ULL hasl = 0;
		int k = 29;
		ULL potk = 1;
		int pol = n/2;
		char c;
		for(int i=0; i<pol; i++)
		{
			cin>>c;
			//potk = potk*k;
			int x = int(c) - 97;
			hasp = hasp*k + (k*x);
			//cout<<hasp<<endl;
		}
		if(n%2==1)
			cin>>c;
		potk = 1;
		for(int i=0; i<pol; i++)
		{
			cin>>c;
			potk = potk*k;
			int x = int(c) - 97;
			hasl = hasl + (potk*x);
		}
		//cout<<hasp<<" "<<hasl<<endl;
		if(hasp==hasl)
		{
			cout<<"TAK";
		}
		else
		{
			cout<<"NIE";
		}
	}
	else
	{
		string s;
		cin>>s;
		int n = s.size();
		ULL hasp = 0;
		ULL hasl = 0;
		int k = 29;
		ULL potk = 1;
		int pol = n/2;
		int j = 0;
		for(int i=0; i<pol; i++)
		{
			//potk = potk*k;
			int x = int(s[j]) - 97;
			hasp = hasp*k + (k*x);
			//cout<<hasp<<endl;
			j++;
		}
		if(n%2==1)
			j++;
		potk = 1;
		for(int i=0; i<pol; i++)
		{
			//cin>>c;
			potk = potk*k;
			int x = int(s[j]) - 97;
			hasl = hasl + (potk*x);
			j++;
		}
		//cout<<hasp<<" "<<hasl<<endl;
		if(hasp==hasl)
		{
			cout<<"TAK";
		}
		else
		{
			cout<<"NIE";
		}
	}
}