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
47
48
49
50
51
52
53
54
55
56
#include <cstdio>
#include <algorithm>

#define MAXN 300003

int n;
char a[MAXN];
char ap[MAXN];
char anp[MAXN];
char b[MAXN];
char bp[MAXN];
char bnp[MAXN];

bool nie = false;

int main()
{
    scanf("%d", &n);
	scanf("%s", a);
	scanf("%s", b);
	
	for(int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			ap[i] = a[i];
			bp[i] = b[i];
			anp[i] = '0';
			bnp[i] = '0';
		}
		else {
			ap[i] = '0';
			bp[i] = '0';
			anp[i] = a[i];
			bnp[i] = b[i];
		}
	}
	
    std::sort(ap, ap+n);
    std::sort(anp, anp+n);
    std::sort(bp, bp+n);
    std::sort(bnp, bnp+n);
    
    for (int i = 0; i < n; i++) {
        if ((ap[i] != bp[i]) || (anp[i] != bnp[i])) {
			nie = true;
			break;
		}
    }
    if (nie) {
		printf("NIE\n");
	} else {
		printf("TAK\n");
	}
    

    return 0;
}