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
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#include <iostream>
#define REP(x, n)  for(int x = 0; x < n; x++)
#define FOR(x, b, e) for (int x = (b); x <= (e); x++)
#define LL long long
#define ULL unsigned long long
#define MP std::make_pair
#define ST first
#define ND second
#define MAX 2000003
// #define MAX 6

using namespace std;
// ios_base::sync_with_stdio(0);


char arr[MAX];
  
/* Driver program to test above function */
int main()
{ 
    std::ios_base::sync_with_stdio(false);
    int N;
    char c;
    // scanf("%d", &N);
    cin>>N;
    if (N == 1){
        cout<<"TAK"<<endl;
        return 0;   
    } 
    if(N != 0){
        // printf("%d\n", std::min(N/2,MAX));
        REP(x,std::min(N/2,MAX)){
            cin>>arr[x];
            // cout<<x<<": "<<arr[x]<<",";
        }
        if(N/2>MAX){
            for(int x=MAX;x<N-MAX;x++){
                cin>>arr[x];
                // cout<<"POM"<< arr[x]<<endl;
            }
        }

        if (N/2<MAX && N%2==1){
            cin>>c;
            // cout<<"SRODEK: "<< ?c<<endl;

        }
        for(int x = std::min(N/2,MAX) - 1; x>=0 ; x--){
            cin>>c;
                        // cout<< c <<endl;

            // cout<<c<<" "<<arr[x];
            if(c!=arr[x]){
                cout<<"NIE"<<endl;
                return 0;
            }
        }
        cout<<"TAK"<<endl;
        
    }
    else{
        queue<char> que;
        int x = 0;
        c='a';
        while(x < MAX && cin>>c ){
            arr[x++]=c;
            // cout<<"a: "<< arr[x-1]<<endl;

        }
        while( x==MAX &&  cin>>c ){
            // cout<<"b: "<< c<<endl;

           que.push(c);
           if(que.size()>=50){
                que.pop();
           }
        }
        if (que.size()==0){
            int half = x/2;
            REP(y, half){
                // cout<<x<<" "<<y <<" "<<arr[y]<<" "<<arr[x-1-y]<<endl;
                if(arr[y] != arr [x-y-1]){
                    cout<<"NIE"<<endl;
                    return 0;
                }
            }
            cout<<"TAK"<<endl;
            return 0;
        }
        else{
            while(que.size() != 0){
                c = que.front();
                // cout<<"Q: "<<c<<endl;
                que.pop();
                if (arr[que.size()]!= c){
                    cout<<"NIE"<<endl;
                    return 0;
                }
            }
        }
        cout<<"TAK"<<endl;


    }

  
    return 0; 
}