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
#include <bits/stdc++.h>

using namespace std;

int p_litery[26][2];
int niep_litery[26][2];

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;

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

    bool mozna = true;

    for (int i = 0; i < n; ++i)
    {
        if (i%2)
        {
            niep_litery[s1[i]-97][0]++;
            niep_litery[s2[i]-97][1]++;
        }

        else
        {
            p_litery[s1[i]-97][0]++;
            p_litery[s2[i]-97][1]++;
        }
    }
    for (int i = 0; i < 26; ++i)
    {
        if (niep_litery[i][0] != niep_litery[i][1] || p_litery[i][0] != p_litery[i][1])
        {
            mozna = false;
            break;
        }
    }
    if (mozna)
        cout << "TAK";
    else
        cout << "NIE";
}