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
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define REP(i, a) FOR(i, 0, a - 1)
#define ST first
#define ND second
#define V vector
#define RS resize
#define EB emplace_back
#define ALL(a) a.begin(), a.end()
#define S(a) (int)a.size()

template<class T> void db(T a) { cerr << a; }
template<class L, class R> void db(pair<L, L> a) { cerr << "(" << a.ST << ", " << a.ND << ")"; }
template<class T> void db(V<T> v) { cerr << "{"; REP(i, S(v)) cerr << (i != 0 ? ", " : ""), db(v[i]); cerr << "}"; }
template<class T> void dump(const char *s, T a) { cerr << s << ": "; db(a); cerr << "\n"; }
template<class T, class... TS> void dump(const char *s, T a, TS... x)
{ while(*s != ',') cerr<< *s++; cerr << ": "; db(a); dump(s + 1, x...); }

#ifdef DEBUG
#define DB(...) dump(#__VA_ARGS__, __VA_ARGS__); 
#else
#define DB(...)
#endif

using LL = long long;
using PII = pair<int, int>;
using VI = V<int>;
using VLL = V<LL>;
using VVI = V<VI>;
using VPII = V<PII>;

LL mod = 1e9 + 696969;
LL base = 31;
LL rev;

LL p(LL b, LL n)
{
	if(n == 0)
		return 1;
	if(n % 2 == 1)
		return (p(b, n - 1) * b) % mod;
	LL x = p(b, n / 2);
	return (x * x) % mod;
}

int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);

    rev = p(base, mod - 2);
    cin.ignore();

    LL a = 0, b = 0;
    char c;
    int n = 0;
    while(cin >> c)
    {
    	n++;
    	a = (a * base) % mod;
    	b = (b * rev) % mod;
    	c -= 'a' - 1;
    	a += c;
    	b += c; 
    }
    b = (b * p(base, n - 1)) % mod;
    cout << (a == b ? "TAK\n" : "NIE\n"); 
}