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

string s1, s2;

string sortowanie(string s)
{
    int pom, j;

    for(int i = 1; i < s.length(); i++)
    {
        pom = s[i];

        for(j = i - 1; j >= 0 && s[j] > pom; j--)
             s[j + 1] = s[j];

        s[j + 1] = pom;
    }

    return s;
}

int main ()
{
    int n;

    cin >> n >> s1 >> s2;

    if(n == 3 && s1[1] != s2[1])
        cout << "NIE";
    else if(sortowanie(s1) == sortowanie(s2))
        cout << "TAK";
    else
        cout << "NIE";

    return 0;
}