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 <bits/stdc++.h>
using namespace std;

int main() {
    std::ios::sync_with_stdio(false);
    int n;
    string s1, s2;
    cin >> n;
    cin >> s1 >> s2;
    bool isSwapable = true;
    
    vector<char> s1_even, s2_even, s1_odd, s2_odd;
    
    for (int i=0; i<n; i++) {
        if (i % 2 == 0) {
            s1_even.push_back(s1[i]);
	    s2_even.push_back(s2[i]);
	} else {
            s1_odd.push_back(s1[i]);
            s2_odd.push_back(s2[i]);
	}
    }
    std::sort(s1_even.begin(), s1_even.end());
    std::sort(s2_even.begin(), s2_even.end());
    std::sort(s1_odd.begin(), s1_odd.end());
    std::sort(s2_odd.begin(), s2_odd.end());
 
    for (int i=0; i<s1_even.size(); i++) {
	if(s1_even[i] != s2_even[i]) {
	    isSwapable = false;
	    break;
	}
    }

    for (int i=0; i<s1_odd.size(); i++) {
        if(s1_odd[i] != s2_odd[i]) {
            isSwapable = false;
	    break;
        }
    }
    
    if (isSwapable) {
    	cout << "TAK" << endl;
    } else {
	cout << "NIE" << endl;
    }

    return 0;
}