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
#include <iostream>
#include <vector>
#include <string>

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(0);
    int n;
    std::cin >> n;
    std::vector<int> firstCountOdd(26);
    std::vector<int> firstCountEven(26);
    std::vector<int> secondCountOdd(26);
    std::vector<int> secondCountEven(26);
    std::string a, b;
    std::cin >> a >> b;
    for (int i = 0; i < n; i++)
    {
        if (i % 2) {
            firstCountOdd[a[i] - 'a']++;
            secondCountOdd[b[i] - 'a']++;
        }
        else {
            firstCountEven[a[i] - 'a']++;
            secondCountEven[b[i] - 'a']++;
        }
    }
    bool out = true;
    for (int i = 0; i < 26; i++)
    {
        if (firstCountEven[i] != secondCountEven[i] || firstCountOdd[i] != secondCountOdd[i]) {
            out = false;
        }
    }
    if (out)
        std::cout << "TAK";
    else
        std::cout << "NIE";
}