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
55
56
57
58
59
60
#include <bits/stdc++.h>

using namespace std;

const int N = 3e6+7;
int n;
string s1, s2;
int s11[N], s12[N], s21[N], s22[N];
int b1, b2;

void printt(int tab[N], int b) {
    for (int i = 0; i < b; i++) {
        cout << tab[i] << " ";
    }
    cout << endl;
}

int main() {
    cin >> n >> s1 >> s2;
    for (int i = 0; i < n; i++) {
        if (i%2) {
            s11[i/2] = int(s1[i]);
            s21[i/2] = int(s2[i]);
            b1++;
        } else {
            b2++;
            s12[i/2] = int(s1[i]);
            s22[i/2] = int(s2[i]);
        }
    }
    //cout << b1 << " asd " << b2 << endl;

    sort(s11, s11 + b1);
    sort(s21, s21 + b1);
    sort(s12, s12 + b2);
    sort(s22, s22 + b2);
    //printt(s11, b1);
    //printt(s21, b1);

    for (int i = 0; i < b1; i++) {
           // cout << "s11 = " << s11[i];
           // cout << " s21 = " << s21[i] << endl;
        if (s11[i] != s21[i]) {
            cout << "NIE";
            return 0;
        }
    }

    for (int i = 0; i < b2; i++) {
          //  cout << "s12 = " << s12[i];
          // cout << " s22 = " << s22[i] << endl;
        if (s12[i] != s22[i]) {
            cout << "NIE";
            return 0;
        }
    }


    cout << "TAK";
}