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

using namespace std;

char tab1[300003];
char tab2[300003];
int z1[200];
int z2[200];

int main(){
    int n;
    cin>>n;
    string s1, s2;
    cin>>s1>>s2;
    if (s1.size()!=s2.size()){
        cout<<"NIE";
        return 0;
    }
    for (int i = 0; i<s1.size(); ++i){
        tab1[i] = s1[i];
    }
    for (int i = 0; i<s2.size(); ++i){
        tab2[i] = s2[i];
    }
    sort(tab1, tab1+s1.size());
    sort(tab2, tab2+s2.size());
    for (int i = 0; i<s1.size(); ++i){
        if (tab1[i]!=tab2[i]){
            cout<<"NIE";
            return 0;
        }
    }
    for (int i = 0; i<s1.size(); i+=2){
        char znak1 = s1[i];
        char znak2 = s2[i];
        ++z1[znak1];
        ++z2[znak2];
    }
    for (int i = 0; i<200; ++i){
        if (z1[i]!=z2[i]){
            cout<<"NIE";
            return 0;
        }
    }
    cout<<"TAK";
    return 0;
}