1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <cstdio>
using namespace std;

const long long p = 53;
const long long m = 1000000009;

int main()
{
    while (getchar() != '\n');
    char c;
    long long hash1 = 0, hash2 = 0;
    long long power1 = 1;
    while ((c = getchar()) >= 'a') {
        hash1 = (hash1 + (c - 'a') * power1) % m;
        power1 = (power1 * p) % m;
        hash2 = (hash2 * p + (c - 'a')) % m;
    }
    puts(hash1 == hash2 ? "TAK" : "NIE");
    return 0;
}