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
#include<cstdio> 
   
const long long POD = 997, MOD = 1e9 + 7;

using namespace std;

int main() { 
    int n;
    scanf("%d", &n);
    char c;
    unsigned int s = 0, o = 0;
    int akt_pot = 1;
    int i = 1;
    c = getchar();
    //printf("%c<<<<<\n", c);
    while(c < 'a' || c > 'z')c = getchar();
    while(c != EOF && c >= 'a' && c <= 'z'){
        //printf("%c<<<<<\n", c);
        s = ((long long)s * POD) % MOD + c;
        s %= MOD;
        o += ((long long)c * akt_pot) % MOD;
        o %= MOD;
        akt_pot = ((long long)akt_pot * POD) % MOD;
        i++;
        c = getchar();
    }
    //printf("%d %d\n", s, o);
    if(s == o)printf("TAK\n");
    else printf("NIE\n");
    return 0; 
}