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

string sbi,sba;
char bip[150007],binp[150007],bap[150007],banp[150007];
int pa, npa;
int n;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> sbi >> sba;
    pa = n/2, npa = (n+1)/2;
    for (int i=0;i<n;i+=2){
        binp[i/2]=sbi[i];
        banp[i/2]=sba[i];
    }
    for (int i=1;i<n;i+=2){
        bip[i/2]=sbi[i];
        bap[i/2]=sba[i];
    }
    sort(binp,binp+npa);
    sort(bip,bip+pa);
    sort(banp,banp+npa);
    sort(bap,bap+pa);
    string wynik="TAK\n";
    for (int i=0;i<npa;i++) if (binp[i]!=banp[i]) wynik="NIE\n";
    for (int i=0;i<pa;i++) if (bip[i]!=bap[i]) wynik="NIE\n";
    cout << wynik;
    return 0;
}