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

using namespace std;

int main()
{
	int n;
	string str;

	cin >> n;

	vector<vector<vector<int>>> toys(2, vector<vector<int>>(2, vector<int>()));

	for (int i = 0; i < 2; ++i)
	{
		cin >> str;

		for (int j = 0; j < n; ++j)
		{
			toys[i][j % 2].push_back(str[j] - 'a');
		}
	}

	for (int i = 0; i < 2; ++i)
	{
		for (int j = 0; j < 2; ++j)
		{
			sort(toys[i][j].begin(), toys[i][j].end());
		}
	}

	bool res = true;

	for (int i = 0; i < 2; ++i)
	{
		if (!res)
			break;

		for (int j = 0; j < toys[0][i].size(); ++j)
		{
			if (toys[0][i][j] != toys[1][i][j]) 
			{
				res = false;
				break;
			}
		}
	}

	if (res)
		cout << "TAK" << endl;
	else
		cout << "NIE" << endl;

	return 0;
}