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
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define PB push_back
#define ALL(c) (c).begin(),(c).end()
#define INT(x) int x; scanf("%d", &x)
#define LINE(n,x) char x[n]; fgets(x, n, stdin)

int n;

void go(char a[]) {
	string a1, a2;
	REP(i,n) (i & 1 ? a2 : a1).PB(a[i]);
	sort(ALL(a1));
	sort(ALL(a2));
	REP(i,n) a[i] = (i & 1 ? a2 : a1)[i >> 1];
}

int main() {
	INT(n1);
	n = n1;
	scanf("\n");
	LINE(300100, a);
	LINE(300100, b);
	go(a);
	go(b);
	printf(strcmp(a, b) ? "NIE\n" : "TAK\n");
}