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
#include <iostream>
using namespace std;

typedef unsigned long long ULL;

ULL modulo = 90000000000077ull;
ULL prime = 7717ull;

int main() {
	int n; cin >> n;
	char c;
	ULL hash = 0ull, hash_b = 0ull, prime_pow = prime;
	while(cin>>c) {
		hash += (c-'a')*prime_pow;
		hash %= modulo;
		prime_pow *= prime;
		prime_pow %= modulo;
		
		hash_b += (c-'a');
		hash_b *= prime;
		hash_b %= modulo;
	}
	
	if(hash == hash_b) {
		cout << "TAK" << endl;
	} else {
		cout << "NIE" << endl;
	}
	return 0;
}