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
#include <iostream>
#include <string>
#include <algorithm>

std::string pick(const std::string& s,bool even)
{
	std::string res;
	for(int i=even?0:1;i<(int)s.length();i+=2)
		res+=s[i];
	return res;
}

std::string sort(std::string s)
{
	std::sort(s.begin(),s.end());
	return s;
}

bool changable(const std::string& a, const std::string& b)
{
	return
		sort(pick(a,true))==sort(pick(b,true)) &&
		sort(pick(a,false))==sort(pick(b,false));
}

int main()
{
	int n;
	std::string a,b;
	std::cin >> n >> a >> b;
    std::cout << (changable(a,b)?"TAK":"NIE");
	return 0;
}