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
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <set>

int main(void)
{
    int n, m;
    std::cin >> n;
    m = n;
    std::multiset<char> even1;
    std::multiset<char> odd1;
    std::multiset<char> even2;
    std::multiset<char> odd2;

    bool flip = true;

    while (m--) {
        char buff;
        std::cin >> buff;
        if (flip) {
            odd1.insert(buff);
        }
        else {
            even1.insert(buff);
        }
        flip = !flip;
    }

    m = n;
    flip = true;
    while (m--) {
        char buff;
        std::cin >> buff;
        if (flip) {
            odd2.insert(buff);
        }
        else {
            even2.insert(buff);
        }
        flip = !flip;
    }

    if(even1 == even2 && odd1 == odd2) {
        std::cout << "TAK\n";
    } else {
        std::cout << "NIE\n";
    }

    return 0;
}