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
40
41
#include <cstdio>
using namespace std;
const int lim = 2;
const long long P[] = {241, 509, 83, 757, 37};
const long long MOD[] = {1059489677,
                         1594898869,
                         759489431,
                         2244895909,
                         359489527,
                         };
long long hasz1[6], hasz2[6], POT[6];
char c;
int n;





int main()
{
    scanf("%d ",&n);
    for(int i = 0; i < lim; i++) POT[i] = 1;
    c = getchar_unlocked();
    while(c >= 'a' && c <= 'z')
    {
        //c = 'a';
        //if(c == '.') break;
        for(int i = 0; i < lim; i++)
        {
            hasz1[i] = (hasz1[i] + (c-'a'+1)*POT[i])%MOD[i];
            hasz2[i] = (hasz2[i] * P[i] + (c-'a'+1)) % MOD[i];
            POT[i] *= P[i];
            POT[i] %= MOD[i];
        }
        c = getchar_unlocked();
    }
    bool ok = true;
    for(int i = 0; i < lim; i++) if(hasz1[i] != hasz2[i]) ok = false;
    if(ok) printf("TAK\n");
    else printf("NIE\n");
}