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
#include <iostream>
#include <cstdio>

using namespace std;

int bitEven[26], bitOdd[26], bajEven[26], bajOdd[26];

int main()
{
    ios_base::sync_with_stdio(0);

    for (int i = 0; i < 26; ++i)
    {
        bitEven[i] = bitOdd[i] = bajEven[i] = bajOdd[i] = 0;
    }

    int n;
    cin >> n;

    string s1, s2;
    cin >> s1;
    cin >> s2;

    for (int i = 0; i < n; ++i)
    {
        if ((i + 1) % 2 == 0)
        {
            bitEven[(int)(s1[i] - 'a')]++;
            bajEven[(int)(s2[i] - 'a')]++;
        }
        else
        {
            bitOdd[(int)(s1[i] - 'a')]++;
            bajOdd[(int)(s2[i] - 'a')]++;
        }
    }

    for (int i = 0; i < 26; ++i)
    {
        if (bitEven[i] != bajEven[i] || bitOdd[i] != bajOdd[i])
        {
            cout << "NIE\n";
            return 0;
        }
    }

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