1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#include <cstdio>
typedef long long LL;

const int mod = 1000000123;
const int p = 4141;

int main() {
    scanf("%*i ");
    char a;
    int pp = 1;
    int h = 0, h_ = 0;
    while((a = getchar()) != '\n') {
        h  = (LL(pp) * a + h) % mod;
        h_ = (LL(h_) * p + a) % mod;
        pp = (LL(pp) * p) % mod;
    }
    printf(h == h_ ? "TAK" : "NIE");
}