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
#include <iostream>
#include <algorithm>

using namespace std;

bool check(int n, string &a, string &b) {
    if(n<3) return a == b;
    string odd_a="", even_a="", odd_b="", even_b="";
    for(int i=0; i<n; ++i)
        if(i&1) {
            even_a+=a[i];
            even_b+=b[i];
        } else {
            odd_a+=a[i];
            odd_b+=b[i];
        }
        
    sort(even_a.begin(), even_a.end());
    sort(even_b.begin(), even_b.end());
    sort(odd_a.begin(), odd_a.end());
    sort(odd_b.begin(), odd_b.end());
    
    return (even_a == even_b) && (odd_a == odd_b);
}

int main() {
    int n;
    string a, b;
    
    cin >> n;
    cin >> a >> b;

    cout << (check(n, a, b) ? "TAK" : "NIE") << endl;

    return 0;
}