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
#include <iostream>
#include <vector>

bool CheckCountAndParity(const std::string& bi, const std::string& ba)
{
	int bi_count[26][2];
	int ba_count[26][2];
	for (int i = 0; i < 26; i++)
	{
		bi_count[i][0] = 0;
		bi_count[i][1] = 0;
		ba_count[i][0] = 0;
		ba_count[i][1] = 0;
	}

	for (int i = 0; i < bi.size(); i++)
	{
		bi_count[bi[i] - 'a'][i%2]++;
		ba_count[ba[i] - 'a'][i%2]++;
	}

	for (int i = 0; i < 26; i++)
	{
		if ((bi_count[i][0] != ba_count[i][0]) || (bi_count[i][1] != ba_count[i][1]))
			return false;
	}

	return true;
}

int main()
{
	int n;
	std::cin >> n;
	std::cin.ignore();

	std::string bi(n, 'a'), ba(n, 'a');

	char c = '0';
	std::cin.get(c);
	for (int i = 0; c != '\n'; i++)
	{
		bi[i] = c;
		std::cin.get(c);
	}

	std::cin.get(c);
	for (int i = 0; c != '\n'; i++)
	{
		ba[i] = c;
		std::cin.get(c);
	}


	if (!CheckCountAndParity(bi, ba))
	{
		std::cout << "NIE";
	}
	else
	{
		std::cout << "TAK";
	}



	return 0;
}