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
#include <iostream>
using namespace std;

const int LETTER_COUNT = 26;

class ToySet {
public:
	int even[LETTER_COUNT] = { 0 };
	int odd[LETTER_COUNT] = { 0 };

	void update(char c, int index) {
		int asciiIndex = int(c) - 97;
		if (index % 2) {
			odd[asciiIndex]++;
		} else {
			even[asciiIndex]++;
		}
	}
};

bool compare(ToySet first, ToySet second) {
	for (int i = 0; i < LETTER_COUNT; i++) {
		if (first.even[i] != second.even[i] || first.odd[i] != second.odd[i]) {
			return false;
		}
	}
	return true;
}

ToySet readToySet(int n) {
	ToySet set = ToySet();

	for (int i = 0; i < n; i++) {
		char c;
		cin >> c;
		set.update(c, i);
	}
	return set;
}

int main() {
	int n;
	cin >> n;

	ToySet firstSet = readToySet(n);
	ToySet secondSet = readToySet(n);

	if (compare(firstSet, secondSet)) {
		cout << "TAK";
	} else {
		cout << "NIE";
	}

	return 0;
}