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
#include <bits/stdc++.h>

using namespace std;

int n, even1[26], odd1[26], even2[26], odd2[26];
string s;

bool check()
{
	for (int i = 0; i < 26; i++)
		if (even1[i] != even2[i] || odd1[i] != odd2[i])
			return false;
	return true;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n;
	cin >> s;
	for (int i = 0; i < n; i += 2)
		++odd1[s[i] - 'a'];
	for (int i = 1; i < n; i += 2)
		++even1[s[i] - 'a'];
	cin >> s;
	for (int i = 0; i < n; i += 2)
		++odd2[s[i] - 'a'];
	for (int i = 1; i < n; i += 2)
		++even2[s[i] - 'a'];

	cout << (check() ? "TAK\n" : "NIE\n");			
}