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
46
//Aleksander Łukasiewicz
#include<bits/stdc++.h>
using namespace std;

#define fru(j,n) for(int j=0; j<(n); ++j)
#define tr(it,v) for(typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define ALL(G) (G).begin(),(G).end()

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int INF = 1000000009;

int p[] = {2017, 3407, 10331, 14369};
int mod[] = {281862667, 1000*1000*1000+7, 1000*1000*1000+9, 1007113333};
int curr[] = {1, 1, 1, 1};
int h[10], revh[10];

int main(){
    int n;
    scanf(" %d\n", &n);
    char x;
    
    while((x = getchar())){
        if(!(x >= 'a' && x <= 'z')) break;
        for(int i=0; i<4; i++){
            h[i] = ((LL)p[i]*h[i] + x)%mod[i];
            revh[i] = ((LL)x*curr[i] + revh[i])%mod[i];
            curr[i] = ((LL)curr[i]*p[i])%mod[i];
        }
    }
    
    for(int i=0; i<4; i++)
        if(h[i] != revh[i]){
            puts("NIE");
            return 0;
        }
    puts("TAK");
    
return 0;
}