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

using namespace std;

int n;
string a, b;

bool check(int start) {
    int occ[128][2];
    for (int i = 0; i < 128; i++)
        for (int j = 0; j < 2; j++)
            occ[i][j] = 0;
    for (int i = start; i < n; i += 2) {
        occ[a[i]][0]++;
        occ[b[i]][1]++;
    }
    
    for (int i = 0; i < 128; i++)
        if (occ[i][0] != occ[i][1])
            return false;
    return true;
}

int main() {
    
    cin >> n;
    cin >> a >> b;
    
    if (!check(0) || !check(1))
        printf("NIE\n");
    else printf("TAK\n");
}