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
50
51
52
53
54
#include<bits/stdc++.h>

using namespace std;
#define toyMapType map<char, int>

class Kid{
    toyMapType even;
    toyMapType odd;

    void addToMap(toyMapType & toyMap, char key){
        if(toyMap.find(key) == toyMap.end()){
            toyMap[key] = 0;
        }
        ++toyMap[key];
    }

    bool map_compare(toyMapType & first, toyMapType & second){
        return first.size() == second.size() && equal(first.begin(), first.end(), second.begin());
    }

public:
    void addToy(int num, char l){
        if(num % 2){
            addToMap(even, l);
        } else{
            addToMap(odd, l);
        }
    }

    bool operator==(Kid & compare){
        return map_compare(even, compare.even) && map_compare(odd, compare.odd);
    }
};

void readToysForKid(int n, Kid & kid){
    for(int i=0; i<n; i++){
        char l; cin >> l;
        kid.addToy(i, l);
    }
}

int main(){
    int n; cin >> n;
    Kid firstKid, secondKid;

    readToysForKid(n, firstKid);
    readToysForKid(n, secondKid);

    if(firstKid == secondKid){
        cout << "TAK\n";
    } else{
        cout << "NIE\n";
    }
}