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

constexpr int MAX = 26;
int n;
int counts1[MAX][2];
int counts2[MAX][2];

bool solve() {
  for (int i=0; i<MAX; i++) {
    if (counts1[i][0] != counts2[i][0]) {
      return false;
    }
    if (counts1[i][1] != counts2[i][1]) {
      return false;
    }
  }
  return true;
}

int main() {
  scanf("%d\n", &n);
  for (int i=0; i<n; i++) {
    char c;
    scanf("%c", &c);
    counts1[(int)(c - 'a')][i % 2] ++;
  }
  scanf("\n");
  for (int i=0; i<n; i++) {
    char c;
    scanf("%c", &c);
    counts2[(int)(c - 'a')][i % 2] ++;
  }
  
  if (solve())  {
    printf("TAK\n");
  } else {
    printf("NIE\n");
  }
  return 0;
}