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
/////////////////////////////////
//////**DOMINIK___KOWALCZYK**////
/////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define boost ios_base::sync_with_stdio(0);
typedef long long ll;
const int MOD[4] = {1e9 + 7, 1e9 + 9, 533335597, 1e9 + 7};
const int POD[4] = {31, 97, 71, 73};
ll cur[4][2];
ll pot[4];

int main()
{
	boost;
	int i;
	cin >> i;

	char s;

	for (i = 0 ; i < 4; i++)pot[i] = 1;

	while (cin >> s)
	{
		for (i = 0; i < 4; i++)
		{
			cur[i][0] += (1ll * pot[i] * (s - 'a' + 1)) % MOD[i];

			cur[i][1] *= POD[i];
			cur[i][1] += (s - 'a' + 1);

			pot[i] *= POD[i];
			pot[i] %= MOD[i];

			cur[i][0] %= MOD[i];
			cur[i][1] %= MOD[i];
		}
	}

	for (i = 0; i < 4; i++)
	{
		if (cur[i][0] != cur[i][1])
		{
			cout << "NIE\n";
			return 0;
		}
	}

	cout << "TAK\n";
	return 0;
}