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;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second

#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end()

using ll = long long;
using pi = pair<int, int>;
using pll = pair<ll, ll>;

using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vpi = vector<pi>;
using vpll = vector<pll>;

int main(){
ios_base::sync_with_stdio(0);
cin.tie();
int n;
string s1,s2,tmp1,tmp2,tmp3,tmp4;
    cin >> n >> s1 >> s2;
    for(int i = 0;i<n;i++){
        if(i % 2){
            tmp1+=s1[i];
            tmp3+=s2[i];
        }
        else{
            tmp2+=s1[i];
            tmp4+=s2[i];
        }
    }
    sort(all(tmp1));
    sort(all(tmp2));
    sort(all(tmp4));
    sort(all(tmp3));
    if(tmp1 == tmp3 && tmp2 == tmp4)
        cout << "TAK";
    else
        cout << "NIE";
}