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

const long long mod1 = 1000000007, a = 29;

int main() {
    int n;
    char l;
    long long h1 = 0, h2 = 0, p = 1;
    scanf("%d", &n);
    l = getchar_unlocked();
    l = getchar_unlocked();
    while (l >= 'a' && l <= 'z') {
        h1 += (l - 'a' + 1) * p;
        h1 %= mod1;
        p *= a;
        p %= mod1;
        h2 *= a;
        h2 += l - 'a' + 1;
        h2 %= mod1;
        l = getchar_unlocked();
    }
    printf(h1 == h2 ? "TAK" : "NIE");
    return 0;
}