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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <cstdio>
#include <cassert>
#include <set>
#include <vector>
#include <map>

int skipWhites() {
    int a = getchar_unlocked();
    while (a == ' ' || a == '\n') {
        a = getchar_unlocked();
    }
    return a;
}

int readInt() {
    int result = 0;
    int a = skipWhites();
    while (a != ' ' && a != '\n' && a != EOF) {
        result = result * 10;
        a-= '0';
        result+=a;
        a = getchar_unlocked();
    }
    if (result < 0) {
        return -1;
    }
    return result;
}

int main() {
//    ios base::sync with stdio(false);
//    cin.tie(nullptr);
    int n = readInt();

    int doZmianyStatsP[26] = {0};
    int stalyStatsP[26] = {0};
    int doZmianyStatsNP[26] = {0};
    int stalyStatsNP[26] = {0};

//    char doZmiany[n];
//    char staly[n];

    int total = 0;
    bool P = true;
    for (int i = 0; i < n; i++) {
        int a = skipWhites();
//        doZmiany[i] = a - 'a';
        if (P) {
            doZmianyStatsP[a - 'a']++;
            P = false;
        } else {
            doZmianyStatsNP[a - 'a']++;
            P = true;
        }
    }
    P = true;
    for (int i = 0; i < n; i++) {
        int a = skipWhites();
//        staly[i] = a - 'a';
        if (P) {
            stalyStatsP[a - 'a']++;
            P = false;
        } else {
            stalyStatsNP[a - 'a']++;
            P = true;
        }
    }

    for (int i = 0; i < 26; i++) {
        if (doZmianyStatsP[i] != stalyStatsP[i]) {
            printf("NIE");
            return 0;
        }
    }
    for (int i = 0; i < 26; i++) {
        if (doZmianyStatsNP[i] != stalyStatsNP[i]) {
            printf("NIE");
            return 0;
        }
    }
    printf("TAK");
}