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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int n;
    string s1, s2;
    cin >> n;
    cin >> s1 >> s2;
    vector<char> a[2];
    vector<char> b[2];
    for(int i = 0; i < n; i++) {
        a[i % 2].push_back(s1[i]);
        b[i % 2].push_back(s2[i]);
    }
    sort(a[0].begin(), a[0].end());
    sort(a[1].begin(), a[1].end());
    sort(b[0].begin(), b[0].end());
    sort(b[1].begin(), b[1].end());
    bool res = ((a[0] == b[0]) and (a[1] == b[1]));
    cout << (res ? "TAK" : "NIE");

    return 0;
}