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
#include <stdio.h>

typedef long long LL;
typedef unsigned long long ULL;

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
#define FORD(i,a,b) for (int i=(a)-1; i>=(b); --i)

#define pb push_back
#define mp make_pair
#define st first
#define nd second

const int MOD = 1000000021;
const int P = 6007;

int main(int argc, char* argv[]) {
  scanf("%*d");

  LL hash0 = 0, hash1 = 0, multiplier = 1;
  char c;
  while (scanf("%c", &c) != EOF) {
    hash0 = (hash0 * P + c) % MOD;
    hash1 = (hash1 + multiplier * c) % MOD;
    multiplier = multiplier * P % MOD;
  }
  if (hash0 == hash1) {
    printf("TAK\n");
  } else {
    printf("NIE\n");
  }
}