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
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
#include <iostream>
#include <unordered_map>

using namespace std;

int main()
{
    unordered_map<char, int> m1even;
    unordered_map<char, int> m1odd;
    unordered_map<char, int> m2even;
    unordered_map<char, int> m2odd;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        char t;
        cin >> t;
        if (i % 2 == 0)
        {
            if (m1even.find(t) == m1even.end())
            {
                m1even.insert(make_pair(t, 1));
            }
            else
            {
                m1even[t]++;
            }
        }

        if (i % 2 == 1)
        {
            if (m1odd.find(t) == m1odd.end())
            {
                m1odd.insert(make_pair(t, 1));
            }
            else
            {
                m1odd[t]++;
            }
        }
    }

    for (int i = 0; i < n; i++)
    {
        char t;
        cin >> t;
        if (i % 2 == 0)
        {
            if (m2even.find(t) == m2even.end())
            {
                m2even.insert(make_pair(t, 1));
            }
            else
            {
                m2even[t]++;
            }
        }

        if (i % 2 == 1)
        {
            if (m2odd.find(t) == m2odd.end())
            {
                m2odd.insert(make_pair(t, 1));
            }
            else
            {
                m2odd[t]++;
            }
        }
    }

    for (auto t : m1even)
    {
        if (m2even.find(t.first) == m2even.end())
        {
            cout << "NIE";
            return 0;
        }
        else if(m2even[t.first]!= t.second)
        {
            cout << "NIE";
            return 0;
        }
    }

    for (auto t : m1odd)
    {
        if (m2odd.find(t.first) == m2odd.end())
        {
            cout << "NIE";
            return 0;
        }
        else if (m2odd[t.first] != t.second)
        {
            cout << "NIE";
            return 0;
        }
    }

    cout << "TAK";

    
    return 0;
}