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

int Bp1[26], Bp2[26], Bn1[26], Bn2[26];

int main () {
	ios_base::sync_with_stdio(0);
	int n;
	string a;
	cin>>n;
	cin>>a;
	if (n % 2 == 1) a += 'a';
	for (int i = 0; i < n; i += 2) {
		++Bn1[a[i]-'a'];
		++Bp1[a[i+1]-'a'];
	}
	cin>>a;
	if (n % 2 == 1) a += 'a';
	for (int i = 0; i < n; i += 2) {
		++Bn2[a[i]-'a'];
		++Bp2[a[i+1]-'a'];
	}
	bool czy  = true;
	for (int i = 0; i < 26; ++i) {
		if (Bp1[i] != Bp2[i]) czy = false;
		if (Bn1[i] != Bn2[i]) czy = false;
	}
	if (czy) cout<<"TAK";
	else cout<<"NIE";
	return 0;
}