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

int main() {
    int n;
    std::cin >> n;
    std::vector<int> evenA, evenB, oddA, oddB;
    for (int i = 0; i < n; i++) {
        char c;
        std::cin >> c;
        if (i % 2 == 0) {
            evenA.push_back((int) c);
        } else {
            oddA.push_back((int) c);
        }
    }
    for (int i = 0; i < n; i++) {
        char c;
        std::cin >> c;
        if (i % 2 == 0) {
            evenB.push_back((int) c);
        } else {
            oddB.push_back((int) c);
        }
    }
    std::sort(evenA.begin(), evenA.end());
    std::sort(evenB.begin(), evenB.end());
    std::sort(oddA.begin(), oddA.end());
    std::sort(oddB.begin(), oddB.end());

    if (evenA == evenB && oddA == oddB) {
        std::cout << "TAK\n";
    } else {
        std::cout << "NIE\n";
    }

    return 0;
}