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

using namespace std;

int counts1[2][26];
int counts2[2][26];

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    string empty;
    string line1;
    string line2;
    getline(cin, empty);
    getline(cin, line1);
    getline(cin, line2);

    for (int i = 0; i < n; i++) {
        char &c1 = line1.at(i);
        counts1[i & 1][c1 - 'a']++;
    }

    for (int i = 0; i < n; i++) {
        char &c2 = line2.at(i);
        counts2[i & 1][c2 - 'a']++;
    }

    for (int i = 0; i < 26; i++) {
        if (counts1[0][i] != counts2[0][i] || counts1[1][i] != counts2[1][i]) {
            cout << "NIE" << endl;
            return 0;

        }
    }

    cout << "TAK" << endl;
    return 0;
}