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
52
53
54
55
56
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (b); i >= (a); --i)
#define TRAV(x,T) for(auto& (x): (T))
#define ALL(T) T.begin(), T.end()
#define TAB(T,a,b) (T)+a, (T)+((b)+1)
#define VAR(x) #x<<" = "<<x<<" " 
#define sz(x) (int)(x).size()
#define nwd __gcd
#define pb push_back
#define st first
#define nd second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
#define deb if(0)
const int N = 25, NT = N + 1;

pii P[NT], NP[NT];

int charToInt(char c) {
    return c - 'a';
}

bool solve() {
    FOR(i, 0, N) {
        if(P[i].st != P[i].nd) return false;
    }
    FOR(i, 0, N) {
        if(NP[i].st != NP[i].nd) return false;
    }
    return true;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    string a, b;
    cin>>n>>a>>b;
    FOR(i, 0, n-1) {
        if(i % 2 == 0) P[charToInt(a[i])].st++;
        else NP[charToInt(a[i])].st++;
        //P[charToInt(a[i])].st++;
    }
    FOR(i, 0, n-1) {
        if(i % 2 == 0) P[charToInt(b[i])].nd++;
        else NP[charToInt(b[i])].nd++;
        //P[charToInt(b[i])].nd++;
    }
    cout<<(solve()? "TAK": "NIE")<<"\n";
    return 0;
}