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 max_n = 1000101;
char a[max_n], b[max_n];
int n;

int pa[2][27];
int pb[2][27];

int main() {
    scanf("%d", &n);
    scanf("%s", a);
    scanf("%s", b);
    for (int i = 0; i < 26; ++i) {
        pa[0][i] = pa[1][i] = pb[0][i] = pb[1][i] = 0;
    }
    for (int i = 0; i < n; ++i) {
        ++pa[i & 1][a[i] - 'a'];
        ++pb[i & 1][b[i] - 'a'];
    }
    for (int i = 0; i < 26; ++i) {
        if (pa[0][i] != pb[0][i] || pa[1][i] != pb[1][i]) {
            printf ("NIE\n");
            return 0;
        }
    }
    printf ("TAK\n");
    return 0;
}