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

using namespace std;

const int primes[123] =
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 97, 101, 103,                // 99   abc
  107, 109, 113, 127, 131, 137, 139, 149, 151, 157, // 109  defghijklm
  163, 167, 173, 179, 181, 191, 193, 197, 199, 211, // 119  nopqrstuvw
  223, 227, 229};                                   // 122  xyz

char c;
const int base = 617;                               // szefo617
long long int h1, h2, ile = 1;

int main() {
  while (scanf("%c", &c) != EOF) if (c >= 'a') {
    h1 = h1 * base + primes[c];
    h2 = h2 + primes[c] * ile;
    ile = ile * base;
  }
  if (h1 == h2) {
    printf("TAK\n");
  } else {
    printf("NIE\n");
  }
  return 0;
}