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

using namespace std;

int P1[26];
int U1[26];
int P2[26];
int U2[26];

int main()
{
	int n;
	cin >> n;
	string toys1, toys2;
	cin >> toys1 >> toys2;
	for(int i = 0; i < n; i++)
	{
		if((i+1)%2 == 1)
		{
			U1[toys1[i]-'a']++;
			U2[toys2[i]-'a']++;
		}
		else
		{
			P1[toys1[i]-'a']++;
			P2[toys2[i]-'a']++;
		}
	}
	bool possible = 1;
	for(int i = 0; i < 26; i++)
	{
		if(U1[i] != U2[i] || P1[i] != P2[i])
		{
			possible = 0;
			break;
		}
	}
	if(possible)
		cout <<"TAK" << endl;
	else
		cout<<"NIE" << endl;
	return 0;
}