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

#ifdef LOCAL
template<class T, class U>
ostream& operator<<(ostream& os, pair<T, U> p) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template<class C, class = typename C::value_type>
typename enable_if<!is_same<C, string>::value, ostream&>::type 
operator<<(ostream& os, C c) {
	for (auto i = c.begin(); i != c.end(); i++) {
		os << " {"[i == c.begin()] << *i << ",}"[next(i) == c.end()];
	}
	return os;
}

#define debug(x) { cerr << #x << " = " << x << endl; }
#else
#define debug(...) {}
#endif

int mod = 1000 * 1000 * 1000 + 9;

const int PN = 2;

int p[4] = {2381, 317, 8461, 3823};
int q[4];
int hasz[4];
int revhasz[4];

bool readchar() {
	char c;
	cin >> c;
	if (cin.eof() || c < 'a' || c > 'z') return false;
	for (int i = 0; i < PN; i ++) {
		hasz[i] = (hasz[i] * (long long)p[i] + c) % mod;
		revhasz[i] = (revhasz[i] + c * (long long)q[i]) % mod;
		q[i] = (q[i] * (long long)p[i]) % mod;
	}
	return true;
}

string answer() {
	for (int i = 0; i < PN; i ++) {
		if (hasz[i] != revhasz[i]) return "NIE";
	}
	return "TAK";
}

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 0; i < PN; i ++) q[i] = 1;
	while (true) {
		if (not readchar()) break;
	}
	cout << answer() << "\n";
}