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
42
43
44
45
#include<bits/stdc++.h>
using namespace std;

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#ifndef _WIN32
    #define getchar getchar_unlocked
#endif

typedef long long lli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
typedef pair<lli, int> pli;
typedef pair<int, lli> pil;

const int mod1=1504382141, mod2=631269439, pod=37;
char c;
lli hasz1[2], hasz2[2], pot1=1, pot2=1;

int main()
{
    c=getchar();
    while((c<'a') || (c>'z'))c=getchar();
    while(1)
    {
        if((c<'a')||(c>'z'))break;
        hasz1[0]=(hasz1[0]+pot1*(c-'a'+1))%mod1;
        hasz2[0]=(hasz2[0]+pot2*(c-'a'+1))%mod2;
        hasz1[1]=(hasz1[1]*pod+(c-'a'+1))%mod1;
        hasz2[1]=(hasz2[1]*pod+(c-'a'+1))%mod2;
        pot1=(pot1*pod)%mod1;
        pot2=(pot2*pod)%mod2;
        c=getchar();
    }
    if((hasz1[0]==hasz1[1])&&(hasz2[0]==hasz2[1]))puts("TAK");
    else puts("NIE");
    return 0;
}

/* 1504382141  631269439 */