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

int main() {
    int n;
    std::cin >> n;
    std::string first, second;
    std::cin >> first >> second;

    std::vector<int> first_stats_even(26), second_stats_even(26);
    std::vector<int> first_stats_odd(26), second_stats_odd(26);


    for(int i = 0; i < n; i++) {
        char f = first[i] - 'a';
        char s = second[i] - 'a';
        if(i %2 == 0) {
            first_stats_even[f]++;
            second_stats_even[s]++;
        } else {
            first_stats_odd[f]++;
            second_stats_odd[s]++;
        }
    }

    bool result = true;

    for(char c = 0; c < 'z'-'a' && result; c++)
        if(first_stats_odd[c] != second_stats_odd[c] ||
           first_stats_even[c] != second_stats_even[c])
           result = false;

    std::cout << (result ? "TAK" : "NIE") << std::endl;
    return 0;

}