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
#include <bits/stdc++.h>

using namespace std;

const int N=300001;
char zabBi[N];
char zabBa[N];

void permute(char * zab,int n) {
    //int m=(n%2)? n/2 : n/2+1;
    int l= (n+1)/2;
    l += (l%2)-1;
    for(int i=1; i< (n+1)/2; i+=2)
        swap(zab[i],zab[l+i]);
}

int main() {
    int n;
    scanf("%d",&n);

    scanf("%s\n", zabBi);
    scanf("%s\n", zabBa);
//  printf("%s\n",zabBi);
//  printf("%s\n",zabBa);
    permute(zabBi,n);
    permute(zabBa,n);
//  printf("%s\n",zabBi);
//  printf("%s\n",zabBa);
    sort(zabBi,zabBi+(n+1)/2);
    sort(zabBi+(n+1)/2,zabBi+n);
    sort(zabBa,zabBa+(n+1)/2);
    sort(zabBa+(n+1)/2,zabBa+n);
//  printf("%s\n",zabBi);
//  printf("%s\n",zabBa);

    for(int i=0; i<n; ++i)
        if(zabBi[i]!=zabBa[i]) { printf("NIE\n"); return 0;}

    printf("TAK\n");
    return 0;
}