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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    string s1,s2;
    int n;
    cin>>n>>s1>>s2;

    if(s1 == s2)
    {
        cout<<"TAK";
        return 0;
    }

    string s1_np,s1_p,s2_np,s2_p;

    for(int i=0; i<s1.size(); ++i)
    {
        if(i%2==0)
        {
            s1_p += s1[i];
            s2_p += s2[i];
        }
        else
        {
            s1_np += s1[i];
            s2_np += s2[i];
        }
    }

    sort(s1_p.begin(), s1_p.end());
    sort(s1_np.begin(), s1_np.end());
    sort(s2_p.begin(), s2_p.end());
    sort(s2_np.begin(), s2_np.end());

    if(s1_p==s2_p && s1_np == s2_np)
        cout<<"TAK";
    else
        cout<<"NIE";

    return 0;
}