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
#include <iostream>
typedef unsigned long long ULL;
using namespace std;

ULL fwd[3], rev[3];
const ULL x[] = {1000000009, 100003, 1013};
ULL x_n[] =     {1000000009, 100003, 1013};


int main()
{
	char curr;
	int size;
	cin >> size;

	while(cin >> curr)
	{
        for(int i = 0; i < 3; ++i)
        {
            fwd[i] += int(curr);
    		fwd[i] *= x[i];
    		rev[i] += (int(curr) * x_n[i]);
    		x_n[i] *= x[i];
        }

	}

	if(fwd[0] == rev[0] && fwd[1] == rev[1] && fwd[2] == rev[2]) cout << "TAK" << endl;
    else cout << "NIE" << endl;
	return 0;
}