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
#include <bits/stdc++.h>
using namespace std;
bool tab[1000004][3];
vector<int> tab1;
vector<int> tab2;
vector<int> tab3;
vector<int> tab4;
int main()
{
    int n, p;
    scanf("%d", &n);
    p=getchar();
    for(int i=1; i<=n; ++i){
        int p=getchar();
        if(i%2==1) tab1.push_back(p);
        else tab2.push_back(p);
    }
    p=getchar();
    for(int i=1; i<=n; ++i){
        int p=getchar();
        if(i%2==1) tab3.push_back(p);
        else tab4.push_back(p);
    }
    sort(tab1.begin(), tab1.end());
    sort(tab2.begin(), tab2.end());
    sort(tab3.begin(), tab3.end());
    sort(tab4.begin(), tab4.end());
    for(int i=0; i<tab2.size(); ++i){
        if(tab1[i]!=tab3[i]){
            cout << "NIE";
            return 0;
        }
        if(tab2[i]!=tab4[i]){
            cout << "NIE";
            return 0;
        }
    }
    if(tab1.size()>tab2.size()){
        if(tab1[tab2.size()]!=tab3[tab2.size()]){
            cout << "NIE";
            return 0;
        }
    }
    cout << "TAK";
    return 0;
}