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

void print(vector<char> v)
{
    for(int i=0; i<v.size(); ++i)
        cout << v[i];
    cout << endl;
}
int main()
{
    ios::sync_with_stdio(0);
    //freopen("in00a.in", "r", stdin);
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;

    //cout << n << endl;
    //cout << a << endl;
    //cout << b << endl;

    vector<char> a1, a2;
    for(int i=0; i<n; i+=2)
        a1.push_back(a[i]);
    for(int i=1; i<n; i+=2)
        a2.push_back(a[i]);

    sort(a1.begin(), a1.end());
    sort(a2.begin(), a2.end());

    //print(a1);
    //print(a2);

    vector<char> b1, b2;
    for(int i=0; i<n; i+=2)
        b1.push_back(b[i]);
    for(int i=1; i<n; i+=2)
        b2.push_back(b[i]);

    sort(b1.begin(), b1.end());
    sort(b2.begin(), b2.end());

    //print(b1);
    //print(b2);

    if(a1==b1 && a2==b2)
        cout << "TAK" << endl;
    else
        cout << "NIE" << endl;
}