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;
typedef long long lld;
typedef double lf;
typedef long double llf;
typedef pair<int,int> pii;
typedef pair<lld,lld> pll;
#define For(i,s,a) for(int i = (int)s; i < (int)a; ++i)
#define rpt(s, it) for(auto it = s.begin(); it != s.end(); ++it)
#define brpt(s, it) for(auto it = s.rend(); it != s.rbegin(); --it)
#define sz size()
#define pb push_back
#define eb emplace_back
#define ff first
#define dd second
#define mp make_pair
#define all(x) (x).begin (x).end()

template<typename Ta, typename Tb>
ostream & operator <<(ostream & os, pair<Ta, Tb> x){
	return os << x.ff << " " << x.dd;
}

char s[3][300001];
char z[3][300001];

int32_t main(void){
	int a;
	scanf("%d", &a);
	scanf("%s", s[0]);
	scanf("%s", z[0]);
	for(int i = 0; i < a; i += 2){
		s[2][i / 2] = s[0][i];
		z[2][i / 2] = z[0][i];
	}
	for(int i = 1; i < a; i += 2){
		s[1][i / 2] = s[0][i];
		z[1][i / 2] = z[0][i];
	}
	int a1 = strlen(s[1]);
	int a2 = strlen(s[2]);
	sort(s[1], s[1] + a1);
	sort(z[1], z[1] + a1);
	sort(s[2], s[2] + a2);
	sort(z[2], z[2] + a2);
	puts(memcmp(s[1], z[1], a1) || memcmp(s[2], z[2], a2) ? "NIE" : "TAK");
}

/*
7
abcdefg
edgbcfa
5
abcde
fghhh
*/