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
#include <iostream>

using namespace std;
#define int long long


#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif


int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin>>n;
  char c;
  int h = 0;
  int rh = 0;
  const int p = 5167;
  const int mod = 1e9 + 33;
  int curP = 1;
  while(cin>>c && isalpha(c)){ 
    c -= 'a';
    h += curP * c;
    h %= mod;
    rh *= p;
    rh += c;
    rh %= mod;
    curP *= p;
    curP %= mod;
  }
  if(h == rh){
    cout<<"TAK\n";
  } else{
    cout<<"NIE\n";
  }
}