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
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int test = 2;
pair <ll, ll> v[] = {
	make_pair(4232147, 1e9+7),
	make_pair(15485857, 1e9+7)
};

struct triple {
	ll h1, h2, pn;
	ll p, mod;
	triple() {}
	triple(ll h1, ll h2, ll pn, ll p, ll mod) : h1(h1), h2(h2), pn(pn), p(p), mod(mod) {}
	
	void next(ll a) {
		this->pn = (this->pn * this->p) % this->mod;
		this->h1 = (this->h1 + (a * this->pn) % this->mod) % this->mod;
		this->h2 = (((a + this->h2) % this->mod) * this->p) % this->mod;
	}
};

int main(){
	ios_base::sync_with_stdio(false);
	
	int N;
	cin >> N;
	
	triple T[test];
	for(int i = 0; i < test; i++) {
		T[i] =  triple(0, 0, 1, v[i].first, v[i].second);
	}
	
	char a;
	while(cin >> a)
	{
		for(int i = 0; i < test; i++) {
			T[i].next((ll) a);
		}
	}
	
	bool res = true;
	
	for(int i = 0; i < test; i++) {
		if(T[i].h1 != T[i].h2) {
			res = false;
			break;
		}
	}
	
	if(res == true) {
		cout << "TAK" << endl;
	} else {
		cout << "NIE" << endl;
	}
	
	return 0;
}