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
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define st first
#define nd second
#define umap unordered_map
#define uset unordered_set
#define watch(x) cerr << (#x) << " is " << (x) << endl
#define all(a) begin(a),end(a)

using namespace std;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
const int inf=0x3f3f3f3f;
const long long llinf=0x3f3f3f3f3f3f3f3f;
const double oo=1e15;
const double eps=1e-8;
const double pi=acos(-1.0);

template<typename T> T sqr(T a_) { return a_*a_; }
template<typename T> T cub(T a_) { return a_*a_*a_; }

inline void readI(int*n){register char c=0,sign=1;while(c<33)c=getchar_unlocked();if(c=='-'){sign=-1;c=getchar_unlocked();}*n=0;while(c>33){*n*=10;*n+=c-'0';c=getchar_unlocked();}*n*=sign;}
// inline void printI(int n){if(!n){putchar_unlocked('0');return;}if(n<0){putchar_unlocked('-');n*=-1;}char digits[12];int i=0;while(n){digits[i++]=(n%10)+'0';n/=10;}while(i--)putchar_unlocked(digits[i]);}
// inline void readLL(long long*n){register char c=0,sign=1;while(c<33)c=getchar_unlocked();if(c=='-'){sign=-1;c=getchar_unlocked();}*n=0;while(c>33){*n*=10;*n+=c-'0';c=getchar_unlocked();}*n*=sign;}
// inline void printLL(long long n){if(!n){putchar_unlocked('0');return;}if(n<0){putchar_unlocked('-');n*=-1;}char digits[24];int i=0;while(n){digits[i++]=(n%10)+'0';n/=10;}while(i--)putchar_unlocked(digits[i]);}
// inline void readS(string*s){register char c=0;while(c<33)c=getchar_unlocked();while(c>=33){*s+=c;c=getchar_unlocked();}}
inline void printS(string s){for(auto c:s)putchar_unlocked(c);}

typedef long double ld;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

//-----------------------------------------------//

const int N=0;
const int M=0;
const int mod=1000005997;

int n;
char c;
ll hA, hB;
ll p=30, pp=1;

int main(){

    readI(&n);

    while((c=getchar_unlocked())){
        if('a'>c || c>'z') break;

        hA*=p;
        hA+=((ll)c-'a'+1);
        hA%=mod;

        hB+=((ll)c-'a'+1)*pp;
        hB%=mod;
        pp*=p;
        pp%=mod;
    }

    printS(hA==hB ? "TAK" : "NIE");

    return 0;
}

//-----------------------------------------------//