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

int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int n;
	std::string a, b;
	std::cin >> n >> a >> b;
	for (int i = 0; i < 2; i++) {
		std::string c, d;
		for (int j = i; j < n; j += 2) {
			c += a[j];
			d += b[j];
		}
		std::sort(c.begin(), c.end());
		std::sort(d.begin(), d.end());
		if (c != d) {
			std::cout << "NIE\n";
			return 0;
		}
	}
	std::cout << "TAK\n";
	return 0;
}