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
45
46
#include <bits/stdc++.h>
using namespace std;
string a,b;
int n,m,z;
vector <int> pa;
vector <int> pb;
vector <int> npa;
vector <int> npb;
int main()
{
	ios_base::sync_with_stdio(0);
    cin>>n>>a>>b;
  	
  	for(int f=0;f<n;f++)
  	{
  		if(f%2==0)
  		{
  			pa.push_back(a[f]);
  			pb.push_back(b[f]);
		}
		if(f%2!=0)
  		{
  			npa.push_back(a[f]);
  			npb.push_back(b[f]);
		}
	}
	sort(pa.begin(),pa.end());
	sort(pb.begin(),pb.end());
	sort(npa.begin(),npa.end());
	sort(npb.begin(),npb.end());
	m=max(max(pa.size(),pb.size()),max(npa.size(),npb.size()));
	//cout<<"m= "<<m<<endl;
	
	for(int f=0;f<m;f++)
	{
		if(pa[f]!=pb[f])
			z=1;
		if(npa[f]!=npb[f])
			z=1;
	}
	if(z==1)
		cout<<"NIE";
	else
		cout<<"TAK";
    return 0;
}