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
#include<stdlib.h>
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>

using namespace std;

long long int N;
unsigned long long int sum = 0;
int DEBUG = 0;
vector<bool> bits;

int char_to_num(char c) {
  return c - 'a';
}

unsigned int parse () {
  char a;
  cin >> N;
  int i;
  unsigned int len = 0, num;
  bool bit;
  getchar();
  if (N == 0) {
    while ((a = getchar()) != EOF && (a != '\n')) {
      num = char_to_num(a);
      for (i = 0; i < 5; i++) {
        bit = (num % 2) ? true : false;
        bits.push_back(bit);
        num /= 2;
      }
      len++;
    }
  } else {
    while (len < N) {
      a = getchar();
      num = char_to_num(a);
      for (i = 0; i < 5; i++) {
        bit = (num % 2) ? true : false;
        bits.push_back(bit);
        num /= 2;
      }
      len++;
    }
  }
  return len;
}

int main () {
  unsigned int len;
  len = parse();
  bool ret = true;
  int j;
  if (DEBUG) cout << "len: " << len << endl;
  for (int i = 0; i < len/2 + 1; ++i) {
    for (j = 0; j < 5; ++j) {
      if (DEBUG) cout << 5*i + j << ": " << bits[5*i + j] << ", " << 5*len - 5 - 5*i + j << ": " << bits[5*len - 5 - 5*i + j] << endl;
      if (bits[5*i + j] != bits[5*len - 5 - 5*i + j]) {
        cout << "NIE" << endl;
        return 0;
      }
    }
  }
  cout << "TAK" << endl;
  return 0;
}