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

using namespace std;

int main() {
	int n;
	cin >> n;
	string a, b;
	cin >> a >> b;
	
	map<char, int> positionsA[2];
	map<char, int> positionsB[2];
	
	for(int i = 0; i < n; ++i) {
		++positionsA[i%2][a[i]];
		++positionsB[i%2][b[i]];
	}
	
	for(int i = 0; i < n; ++i) {
		if(positionsA[0][a[i]] != positionsB[0][a[i]]) {
			cout << "NIE" << endl;
			return 0;
		}
		if(positionsA[0][b[i]] != positionsB[0][b[i]]) {
			cout << "NIE" << endl;
			return 0;
		}
		if(positionsA[1][a[i]] != positionsB[1][a[i]]) {
			cout << "NIE" << endl;
			return 0;
		}
		if(positionsA[1][b[i]] != positionsB[1][b[i]]) {
			cout << "NIE" << endl;
			return 0;
		}
	}
	cout << "TAK" << endl;
	return 0;
}