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
#include <stdio.h>

using namespace std;

const unsigned long long p = 1e9 + 7;
const unsigned long long q = 1e9 + 9;


int main() {
    unsigned long long len; int c;
    scanf("%llu", &len);
    c = getchar();

    unsigned long long nrmHash = 0;
    unsigned long long revHash = 0;

    len = 0;
    unsigned long long power = 1;
    while (EOF != (c = getchar())) {
        if (c == '\n') {
            break;
        }

        nrmHash = (((nrmHash * q) % p) + c) % p;
        revHash = (revHash + ((c * power) % p)) % p;
        
        power = (power * q) % p;
        len++;
    }


    if (nrmHash != revHash) {
        printf("NIE\n");
    } else {
        printf("TAK\n");
    }

    return 0;
}