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
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;
int n;
long long hl,hp,pot=1,zm=31,mod=1000000007;
char ch;
int main()
{
    ios_base::sync_with_stdio(false);
    cin>>n;
    while(cin>>ch)
    {
        hl+=(ch-'a'+1)*pot%mod;
        hl%=mod;
        hp*=zm;
        hp%=mod;
        hp+=(ch-'a'+1);
        hp%=mod;
        pot*=zm;
        pot%=mod;
    }
    if(hl==hp) cout<<"TAK\n";
    else cout<<"NIE\n";
    return 0;
}