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
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define PB push_back
#define ST first
#define ND second

pll base=pll(29, 31);
const pll mod = pll(1e9+7, 1e9+9);

pll operator+(const pll a, const pll b) { return pll(a.ST+b.ST, a.ND+b.ND); }
pll operator*(const pll a, const pll b) { return pll(a.ST*b.ST, a.ND*b.ND); }
pll operator%(const pll a, const pll b) { return pll(a.ST%b.ST, a.ND%b.ND); }


int main()
{
	int n;
	pll a=pll(0,0), b=pll(0,0), p=pll(1,1);
	char c;
	while(true)
	{
		c = getc(stdin);
		if('a' <= c && c <= 'z')
			break;
	}
	do
	{
		pll x = pll(c - 'a', c - 'a');
		a = (a+p*x)%mod;
		b = (base*b + x)%mod;
		p = (p*(base))%mod;
	}while((c = getc(stdin)) >= 'a');
	a = (a%mod+mod)%mod;
	b = (b%mod+mod)%mod;
	if(a == b)
		printf("TAK\n");
	else
		printf("NIE\n");
	
	return 0;
}