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

const int N = 300002;

int main() {
  int n; scanf("%d", &n);
  char x[N], y[N]; scanf("%s %s", &x, &y);

  int c[26];
  for (int i=0; i<26; ++i) c[i] = 0;
  for (int i=0; i<n; i+=2) {
    c[x[i]-'a']++;
    c[y[i]-'a']--;
  }
  for (int i=0; i<26; ++i) if (c[i] != 0) {
    printf("NIE\n");
    return 0;
  }
  for (int i=1; i<n; i+=2) {
    c[x[i]-'a']++;
    c[y[i]-'a']--;
  }
  for (int i=0; i<26; ++i) if (c[i] != 0) {
    printf("NIE\n");
    return 0;
  }
  printf("TAK\n");
  return 0;
}