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

const long long PRIME = 6820076854994569;
const long long BASE = 191;


int main() {
  int n;
  scanf("%d ", &n);
  
  char c;
  long long h1 = 0;
  long long h2 = 0;
  long long mult = 1;
  while (true) {
    c = getchar();
    if (c < 'a' || c > 'z') break;

    h1 = (h1 * BASE + c)%PRIME;
    h2 = (h2 + mult * c)%PRIME;
    mult = (mult*BASE)%PRIME;
    // fprintf(stderr, "%lld\n", mult);
  }

  if (h1 == h2) {
    printf("TAK\n");
  } else {
    printf("NIE\n");
  }

  return 0;
}