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 <cstdio>
#include <iostream>

using namespace std;

#define I unsigned long


I p[]= {
      2,      3,      5,      7,     11,     13,     17,     19,     23,     29,
};
I pn[10];
I r1[10];
I r2[10];

int main()
{
    int n,c;
    int h = 10;
    scanf("%d",&n);
    for (int i=0;i<h;i++) pn[i]=1;
    while((c = getchar()) != EOF) {
        if(c >= 'a' && c <='z') {
            for (int i=0;i<h;i++) {
                r1[i]=(r1[i]+pn[i]*c);
                r2[i]=(r2[i]*p[i]+c);
                pn[i]=(pn[i]*p[i]);
            }
        }
    }
    for(int i=0;i<h;i++) {
        //cout << i << " " << r1[i] << " " << r2[i] << "\n";
        if (r1[i]!=r2[i]) {
            printf("NIE\n");
            return 0;
        }
    }
    printf("TAK\n");
}