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
#include <iostream>
#define SIZE 300010

using namespace std;

inline int asciiToNum(char c){
    return c-97;
}

int main(){

    int n;
    char bitus[SIZE];
    char bajtus[SIZE];

    scanf("%d", &n);

    scanf("%s", bitus);
    scanf("%s", bajtus);

    int occurrences[2][2][26];
    for(int k = 0; k<2;k++)
        for(int i = 0 ;i<2; i++)
            for(int j = 0; j<26;j++)
                occurrences[k][i][j]=0;

    for(int i = 0; i<n; i++){
        occurrences[0][i%2][asciiToNum(bitus[i])]+=1;
    }
    for(int i = 0; i<n; i++){
        occurrences[1][i%2][asciiToNum(bajtus[i])]+=1;
    }
    bool flag = true;
    for(int i = 0 ;i<2; i++)
        for(int j = 0; j<26;j++)
            if(occurrences[0][i][j]!=occurrences[1][i][j]) flag= false;
    if(flag){
        printf("TAK\n");
    }
    else{
        printf("NIE\n");
    }

    return 0;
}