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
#include<iostream>
using namespace std;

const int M = 27;
int counter1[M];
int counter2[M];

void zeros() {
    for (int i = 0; i < M; i++)
        {
            counter1[i] = 0;
            counter2[i] = 0;
        }
}

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;

    string toys1, toys2;
    cin>>toys1>>toys2;

    zeros();

    char c;
    int numb;
    for (int i = 0; i < n; i+=2)
    {
        c = toys1[i];
        numb = c - 96;
        
        counter1[numb]++;

        c = toys2[i];
        numb = c - 96;
        
        counter2[numb]++;
    }
    
    for (int i = 1; i < M; i++)
    {
        if (counter1[i] != counter2[i]) {
            cout<<"NIE\n";
            return 0;
        }
    }
    
    zeros();

    for (int i = 1; i < n; i+=2)
    {
        c = toys1[i];
        numb = c - 96;
        
        counter1[numb]++;

        c = toys2[i];
        numb = c - 96;
        
        counter2[numb]++;
    }
    
    for (int i = 0; i < M; i++)
    {
        if (counter1[i] != counter2[i]) {
            cout<<"NIE\n";
            return 0;
        }
    }

    cout<<"TAK\n";
    return 0;
}