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

int pattern[26];
pair<bool,bool> paritys[26];
pair<bool,bool> paritys1[26];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    string s,s1;

    cin >> n;
    cin >> s >> s1;

    for(int i=0; i<n; i++){
        pattern[s[i]-'a']++;
        pattern[s1[i]-'a']--;
        if(i%2==0){
            if(paritys[s[i]-'a'].second==false) paritys[s[i]-'a'].second=true;
            if(paritys1[s1[i]-'a'].second==false) paritys1[s1[i]-'a'].second=true;
        }
        if(i%2==1){
            if(paritys[s[i]-'a'].first==false) paritys[s[i]-'a'].first=true;
            if(paritys1[s1[i]-'a'].first==false) paritys1[s1[i]-'a'].first=true;
        }
    }
    
    for(int i=0; i<26; i++){
        if(pattern[i]!=0){
            cout << "NIE";
            return 0;
        }
    }

    for(int i=0; i<26; i++){
        if(paritys[i].first!=paritys1[i].first || paritys[i].second!=paritys1[i].second){
            cout << "NIE";
            return 0;
        }
    }

    cout << "TAK";
    return 0;

}