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

using namespace std;

int n;
int s1p[26];
int s1np[26];
int s2p[26];
int s2np[26];

char c;

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i<n; ++i){
        cin >> c;
        if(i%2 == 0){
            ++s1p[int(c)-'a'];
        }else{
            ++s1np[int(c)-'a'];
        }
    }
    for(int i = 0; i<n; ++i){
        cin >> c;
        if(i%2 == 0){
            ++s2p[int(c)-'a'];
        }else{
            ++s2np[int(c)-'a'];
        }
    }
    bool poss = true;
    for(int i = 0; i<26; ++i){
        if(s1p[i] != s2p[i]){
            poss = false;
        }
        if(s1np[i] != s2np[i]){
            poss = false;
        }
    }
    poss ? (cout << "TAK") : (cout << "NIE");
    return 0;
}