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

using namespace std;
using LL = long long;

constexpr LL MOD = 1000 * 1000 * 1000 + 7, BASE = 1000 * 1000 * 1000 + 9;

void initialize()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main()
{
    initialize();

    int n;
    cin >> n;

    char c;
    LL h1 = 0, h2 = 0;
    LL y = 1;
    while (cin >> c)
    {
        LL x = c - 'a';
        h1 *= BASE;
        h1 += x;
        h1 %= MOD;
        h2 += x * y;
        h2 %= MOD;
        y *= BASE;
        y %= MOD;
    }

    if (h1 == h2)
        cout << "TAK\n";
    else
        cout << "NIE\n";

    return 0;
}