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
#include <bits/stdc++.h>
#define lld unsigned long long
#ifdef __linux__
#define gcx getchar_unlocked()
#elif WIN32
#define gcx getchar()
#endif

using namespace std;

char c;
lld a,b,d,e,r=1,rr=1;

int main()
{
    while(c!=10) c=gcx;
    c=gcx;
    while(c>96)
    {
        //cout<<"wykonuje sie"<<endl;
        c-=97;
        a=a+r*(lld)c;
        a=a%2846409743;
        b=(b*29+c)%2846409743;
        r=(r*29)%2846409743;
        
        d=d+rr*(lld)c;
        d=d%1000001273;
        e=(e*29+c)%1000001273;
        rr=(rr*29)%1000001273;
        
        c=gcx;
    }
    //printf("%lld %lld\n",a,b);
    if(a==b&&d==e) puts("TAK");
    else puts("NIE");
    return 0;
}