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
50
51
#include <bits/stdc++.h>
#ifdef SIO
#define dbg(name) cerr << #name ": " << (name) << "\t"
#define nl cerr<<endl
#else
#define dbg(name)
#define nl
#endif
#define st first
#define nd second
#define pb push_back
#define rep(i,begin,end) for(__typeof(end) i = begin; i <= end; i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const ll nax = 1e18+33;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    string s, t;
    cin >> n;
    cin >> s >> t;
        
    vector<int> L(30);
    vector<pii> S,T;
    
    rep(i,0,n-1) {
        int x = s[i] - 'a';
        S.pb({x,i%2});
        L[x]++;
    }
    
    rep(i,0,n-1) {
        int x = t[i] - 'a';
        T.pb({x,i%2});
        L[x]--;
    }
    
    rep(i,'a'-'a','z'-'a')
        if(L[i] != 0) {
            cout << "NIE\n";
            return 0;
        }

    sort(S.begin(),S.end());
    sort(T.begin(),T.end());

    cout << (S==T?"TAK\n":"NIE\n");

}