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

using namespace std;

int main()
{
    int n;
    cin>>n;

    string s1, s2;
    string zabawki1_parz = "";
    string zabawki1_nieparz = "";
    string zabawki2_parz = "";
    string zabawki2_nieparz = "";

    cin>>s1>>s2;
    for(int i = 0; i < n; i++)
    {
        if(i%2 == 0)
        {
            zabawki1_parz += s1[i];
            zabawki2_parz += s2[i];
        }
        else
        {
            zabawki1_nieparz += s1[i];
            zabawki2_nieparz += s2[i];
        }
    }

    sort(zabawki1_parz.begin(),    zabawki1_parz.end());
    sort(zabawki1_nieparz.begin(), zabawki1_nieparz.end());
    sort(zabawki2_parz.begin(),    zabawki2_parz.end());
    sort(zabawki2_nieparz.begin(), zabawki2_nieparz.end());

    s1 = zabawki1_nieparz + zabawki1_parz;
    s2 = zabawki2_nieparz + zabawki2_parz;

    if(s1 == s2)
        cout<<"TAK";
    else
        cout<<"NIE";

    return 0;
}