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
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;

string sort2(string x)
{
	char temp;
	for (int i = 0; i < x.length()-2; i++) {
		for (int j = i + 2; j < x.length(); j = j + 2) {
			if (x[i] > x[j])
			{
				temp = x[i];
				x[i] = x[j];
				x[j] = temp;
			}
		}
	}
	return x;
}
bool sameLetters(string a,string b)
{
	if (a.length() != b.length())
		return false;
	a = sort2(a);
	b = sort2(b);
	for (int i = 0; i < a.length(); i++) {
		if (a[i] != b[i])
			return false;
	}
	return true;
}

int main()
{
	int n;
	string a,b;
	cin >> n >> a >> b;
	if (!sameLetters(a,b)) {
		cout << "NIE";
	}
	else {
		cout << "TAK";
	}
	return(0);
}