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>

using namespace std;

int licz(string tekst, char litera)
{
	int ile = 0;

	for (int i = 0; i < tekst.size(); i++)
		if (tekst[i] == litera) ile++;

	return ile;
}

int main()
{
	string alphabet="abcdefghijklmnopqrstuvwxyz", initial, outcome;
	int word_length;
	bool flag = true;

	cin >> word_length >> initial >> outcome;

	for (int i = 0; i < 26; i++)
		if (licz(initial, alphabet[i]) != licz(outcome, alphabet[i]))
			flag = false;
	
	if (word_length % 2 == 0)
		for (int i = 0; i < word_length; i++)
		{
			
			if ((initial[i] == outcome[word_length - i-1] && initial[word_length - i-1] == outcome[i]) && initial[i] != outcome[i] && initial[word_length - i - 1] != outcome[word_length - i - 1])
				flag = false;

		}
	

	if (flag) cout << "TAK";
	else cout << "NIE";

	return 0;
}