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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <bits/stdc++.h>
using namespace std;
using ll  = long long;
using Vi  = vector<int>;
using Pii = pair<int,int>;
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define rep(i,b,e) for(int i=(b); i<(e); i++)
#define each(a,x)  for(auto& a : (x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int((x).size())
#define endl "\n"
const long long inf = 2e17 + 10;


long long mod1 = 1000000007, mod2 = 1000696969;
long long pot1 = 353, pot2 = 277;
long long sporo = 1e15;


void solve(){
	int n;
	cin >> n;
	char c;
	long long x1 = 0,x2 = 0;
	long long y1 = 0,y2 = 0;
	long long m1 = 1, m2 = 1;
	while( cin >> c ){
		//cout << c << endl;
		if( c == '\n' )
			break;
		x1 *= pot1;
		x1 += (int)c;
		if( x1 > sporo)
			x1 %= mod1;
		x2 *= pot2;
		x2 += (int)c;
		if( x2 > sporo )
			x2 %= mod2;

		y1 += (int)c*m1;
		if( y1 > sporo )
			y1 %= mod1;
		y2 += (int)c*m2;
		if( y2 > sporo )
			y2 %= mod2;

		m1 *= pot1;
		if( m1 > sporo )
			m1 %= mod1;
		m2 *= pot2;
		if( m2 > sporo )
			m2 %= mod2; 
	}
	//cout << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
	if( x1%mod1 == y1%mod1 && x2%mod2 == y2%mod2 ){
		cout << "TAK" << endl;
	}else {
		cout << "NIE" << endl;
	}
}

void clear(){
}

int main() {
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(10);
	int z = 1;
	//cin >> z;
	for(int i = 0; i < z; i++){
		solve();
		clear();
	}
}