1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int z; cin >> z;
    string s, t; cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    if (s != t)
        cout << "NIE" << endl;
    else
        if (z % 2 == 0 && (s[0] == t[z - 1] || s[z - 1] == t[0]))
            cout << "NIE" << endl;
        else
            cout << "TAK" << endl;

    return 0;
}