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

using namespace std;

void readToys(vector<vector<int>>& toysOnPositions,
			  int toysCount) {
	for (int i = 0; i < toysCount; ++i) {
		char toy;
		cin >> toy;
		toysOnPositions[i % 2][toy - 'a']++;
	}
}

bool areToysTheSame(vector<vector<int>>& bitToysOnPositions,
					vector<vector<int>>& byteToysOnPositions) {
	for (int i = 0; i < bitToysOnPositions[0].size(); ++i) {
		if (bitToysOnPositions[0][i] != byteToysOnPositions[0][i])
			return false;

		if (bitToysOnPositions[1][i] != byteToysOnPositions[1][i])
			return false;
	}

	return true;
}

int main() {
	int toysCount;
	cin >> toysCount;
	vector<vector<int>> bitToysOnPositions(2, vector<int>('z' - 'a' + 1, 0));
	vector<vector<int>> byteToysOnPositions(2, vector<int>('z' - 'a' + 1, 0));
	readToys(bitToysOnPositions, toysCount);
	readToys(byteToysOnPositions, toysCount);

	if (areToysTheSame(bitToysOnPositions, byteToysOnPositions)) {
		cout << "TAK" <<  endl;
	} else {
		cout << "NIE" << endl;
	}

	return 0;
}