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
#include <iostream>
#include <map>
using namespace std;

map<int, map<char, int>> m_input;
map<int, map<char, int>> m_output;

string alphabet = "abcdefghijklmnopqrstuvwxyz";
int n;
char input_string[300001];
char output_string[300001];
int is_even = 0;
char input_sign, output_sign;

int main()
{
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> input_string[i];
    }
    for(int i = 0; i < n; i++){
        cin >> output_string[i];
    }


    map<char, int> m1;
    for(auto s: alphabet){
        m1[s] = 0;
    }
    m_input[0] = m1;
    m_input[1] = m1;
    m_output[0] = m1;
    m_output[1] = m1;

    for(int i = 0; i < n; i++){
        is_even = i % 2;
        input_sign = input_string[i];
        output_sign = output_string[i];
        m_input[is_even][input_sign] += 1;
        m_output[is_even][output_sign] += 1;
    }
    for(int i = 0; i <= 1; i++){
        for(const auto &myPair : m_input[i]){
            if(myPair.second != m_output[i][myPair.first]){
                cout << "NIE" << endl;
                return 0;
            }
        }
    }
    cout << "TAK" << endl;
    return 0;
}