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

int n;
char c;

int BitA[26], BitB[26];
int BajA[26], BajB[26];

int main()
{
    scanf("%d",&n);

    for (int i = 0; i < n; i++)
    {
        scanf(" %c",&c);
        int pos = ((int)c-97);
        if (i%2 == 0) BitA[pos]++;
        else BitB[pos]++;
    }

    for (int i = 0; i < n; i++)
    {
        scanf(" %c",&c);
        int pos = ((int)c-97);
        if (i%2 == 0) BajA[pos]++;
        else BajB[pos]++;
    }

    bool valid = true;

    for (int i = 0; i < 26; i++)
    {
        if (BitA[i] != BajA[i] || BitB[i] != BajB[i]) valid = false;
    }
    
    if (valid)
    {
        printf("TAK");
    }
    else
    {
        printf("NIE");
    }
}