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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iPair;
typedef pair<ll,ll> llPair;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<iPair> viP;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int modulo = 1e9 + 7; 
#define forr(i, b, e) for (int i = b; i < e; ++i)
#define ford(i, b, e) for (int i = b; i >= e; --i)
#define fort(i, x) for (auto &i : (x))
#define sze(x) ((int)x.size())
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define sp <<" "
#define spa <<" "<<
#define el <<"\n"

const int NMAX = 300 * 1000;
int n;
string a, b;

int alet[26], blet[26];
int al[26], ar[26], bl[26], br[26];

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

	cin >> n;
	cin >> a;
	cin >> b;

	forr(i, 0, n) {
		alet[int(char(a[i])-'a')]++;
		blet[int(char(b[i])-'a')]++;
	}

	bool good = 1;
	forr (i, 0, 26) 
		if (alet[i] != blet[i])
			good = 0;

	if (!good) {
		cout << "NIE\n";
		return 0;
	} 

	for(int i = 0; i < n; i+=2) {
		al[int(char(a[i])-'a')]++;
		bl[int(char(b[i])-'a')]++;
	}

	for(int i = 1; i < n; i+=2) {
		ar[int(char(a[i])-'a')]++;
		br[int(char(b[i])-'a')]++;
	}

	forr (i, 0, 26) 
		if (al[i] != bl[i])
			good = 0;

	forr (i, 0, 26) 
		if (ar[i] != br[i])
			good = 0;

	if (!good) {
		cout << "NIE\n";
		return 0;
	} 
	else
		cout << "TAK\n";

	return 0;
}