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

int main()
{
    size_t n;
    std::cin >> n;

    std::string bitus;
    std::string bajtus;
    bitus.reserve(n+1);
    bajtus.reserve(n+1);
    std::cin >> bitus >> bajtus;

    assert(n == bitus.length());
    assert(n == bajtus.length());

    std::vector<int> bitusCounts[2] = {
        std::vector<int>(26, 0),
        std::vector<int>(26, 0),
    };
    std::vector<int> bajtusCounts[2] = {
        std::vector<int>(26, 0),
        std::vector<int>(26, 0),
    };
    for (size_t i = 0; i < n; i++)
        ++bitusCounts[i & 1][bitus[i] - 'a'];
    for (size_t i = 0; i < n; i++)
        ++bajtusCounts[i & 1][bajtus[i] - 'a'];

    if (bitusCounts[0] == bajtusCounts[0] && bitusCounts[1] == bajtusCounts[1])
        std::cout << "TAK\n";
    else
        std::cout << "NIE\n";
    return 0;
}