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

#define ll long long

int main() {
    std::ios::sync_with_stdio(false);
    using namespace std;
    int n;
    cin >> n;
    string A, B,
           A1((n + 1) / 2, 'x'), A2(n / 2, 'x'),
           B1((n + 1) / 2, 'x'), B2(n / 2, 'x');
    cin >> A >> B;
    for(int i = 0; i < n; i += 2)
        A1[i / 2] = A[i];
    for(int i = 0; i < n; i += 2)
        B1[i / 2] = B[i];
    for(int i = 1; i < n; i += 2)
        A2[i / 2] = A[i];
    for(int i = 1; i < n; i += 2)
        B2[i / 2] = B[i];
    sort(A1.begin(), A1.end());
    sort(A2.begin(), A2.end());
    sort(B1.begin(), B1.end());
    sort(B2.begin(), B2.end());

    /*
    cout << A1 << " " << B1 << "\n";
    cout << A2 << " " << B2 << "\n";
    */

    if(A1 == B1 && A2 == B2)
        cout << "TAK\n";
    else
        cout << "NIE\n";

    return 0;
}