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
#include "bits/stdc++.h"

using namespace std;

vector <char> c1;
vector <char> c2;

int main()
{
    int n;
    string p1;
    string p2;
    int l = 0;

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n;
    cin >> p1;
    cin >> p2;

    c1.reserve(n);
    c2.reserve(n);

    for (int i = 0; i < n; i++)
    {
        c1.push_back(p1[i]);
        c2.push_back(p2[i]);
    }

    sort(c1.begin(), c1.end());
    sort(c2.begin(), c2.end());

    for (int i = 0; i < n; i++)
        if (c1[i] != c2[i])
            l++;

    if (l > 0)
        cout << "NIE";
    else
        cout << "TAK";

    exit(0);
}