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

using namespace std;
vector <char> a[2], b[2];
int n;
int main() {
    cin >> n;

    for (int i = 1; i <= n; i++) {
        char c;
        cin >> c;
        a[i%2].push_back(c);
    }

    for (int i = 1; i <= n; i++) {
        char c;
        cin >> c;
        b[i%2].push_back(c);
    }
    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());
    if ((a[0] == b[0]) && (a[1] == b[1])) {
        cout << "TAK" << endl;
    } else {
        cout << "NIE" << endl;
    }
    return 0;
}