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
69
70
71
72
73
74
75
76
// Author: Krzysztof Bochenek
// Email:  kpbochenek@gmail.com
// --------------------------------
#include <stdio.h>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <math.h>
#include <algorithm>
#include <string>
#include <iostream>
#include <climits>
#include <time.h>

#define pb push_back
#define mp make_pair

using namespace std;


typedef long long int ll;
typedef unsigned long long ull;

#define rep(i, n) for(int i=0; i<n; ++i)

const int maxV = 800000;
char a[maxV];

int x[256];

int main() {
  srand(time(NULL));

  char c;
  int cnt = 0;
  int length = 0;

  cin >> length;
  
  bool over = false;
  while(cin >> c) {
    a[cnt++] = c;
    x[c]++;
    if (cnt >= maxV) {
      over = true;
      break;
    }
  }

  bool palindrome = true;
  if (over) {
    while(cin >> c) { x[c]++; }
    int odd = 0;
    for (int i=0; i<256; ++i) {
      if (x[i] % 2 == 1) odd++;
    }
    palindrome = (rand() % 2 == 0) && odd < 2;
  } else {
    cnt--;
    for (int i=0; i<cnt; ++i, --cnt) {
        if (a[i] != a[cnt]) {
        palindrome = false;
        break;
        }
    }
  }

  if (palindrome) {
    cout << "TAK" << endl;
  } else {
    cout << "NIE" << endl;
  }

  return 0;
}