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
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;

void solve()
{
    int n;
    string s1, s2;
    cin >> n;
    cin >> s1 >> s2;
    vector<int> s1_odd(26, 0);
    vector<int> s2_odd(26, 0);
    vector<int> s1_even(26, 0);
    vector<int> s2_even(26, 0);
    vector<int> data(n);
    for (int i = 0; i < n; i++)
    {
        char c = s1[i];
        if (i % 2 == 0)
        {
            s1_even[c - 'a']++;
        }
        else
        {
            s1_odd[c - 'a']++;
        }
    }
    for (int i = 0; i < n; i++)
    {
        char c = s2[i];
        if (i % 2 == 0)
        {
            s2_even[c - 'a']++;
        }
        else
        {
            s2_odd[c - 'a']++;
        }
    }
    for (int i = 0; i < 26; i++)
    {
        if (s1_even[i] != s2_even[i] or s1_odd[i] != s2_odd[i])
        {
            cout << "NIE" << endl;
            return;
        }
    }
    cout << "TAK" << endl;
}

int main()
{
    solve();
    return 0;
}