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


int main()
{
    uint32_t n;
    std::cin >> n;

    uint8_t base = 26;
    uint64_t mod = 709490156681136600;
    uint64_t exponent = 1;
    uint64_t forward = 0;
    uint64_t reverse = 0;
    char c;
    while (std::cin >> c)
    {
        c = c - 'a';

        forward = (forward * base) % mod + c;
        reverse = (reverse + c * exponent) % mod;
        exponent = (exponent * base) % mod;
    }

    if (forward == reverse)
        std::cout << "TAK" << std::endl; //lets hope so
    else
        std::cout << "NIE" << std::endl;
    return 0;
}