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
#include <bits/stdc++.h>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#pragma GCC optimize ("O3")
//using namespace __gnu_pbds;
using namespace std;
#define ff first
#define dd second
#define mp make_pair
typedef uint_fast64_t lld;
#define pb emplace_back
#define sz size()
#define For(i,s,a) for(lld i=(lld)s;i<(lld)a;++i)
typedef pair<int,int> pii;
typedef pair<lld,lld> pll;
#define rpt(S,it) for(auto it=S.begin();it!=S.end();++it)
//#define mod (lld)(1e9+7)
#define scanf(...) scanf(__VA_ARGS__)?:0
#define P first
#define S second
#ifdef __WIN32__
#define gcx getchar
#elif __linux__
#define gcx getchar_unlocked
#endif
#define piii pair<pii,pii>
//template<typename T>
#define T lld
inline void scan(T *i)
{
	register T t=0;
	register char z='a';
	register bool neg=0;
	while(z<'0' || z>'9'){if(z=='-')neg^=1;
	z=gcx();}
	while(z>='0' && z<='9')
	{
		t=(t<<3ll)+(t<<1ll)+z-'0';
		z=gcx();
	}
	if(neg)t=~(t-1);
	*i=t;
}

const lld m=1e9+696969;
const lld m1=1e9+5858587;
const lld base=43;
const lld base1=31;
 lld basel=43;
 lld basel1=31;
#define mod(x,d) x=((x>d)?x%d:x)


int main()
{
	srand(69696969);
	int a;
	scanf("%d", &a);
	getchar();
	//int A=20000000;
	register char c='4';
	lld l=0,p=0,l1=0,p1=0;
	
	a=0;
	while((c=getchar_unlocked())!=EOF){
		if(c==' ' || c=='\n')break;
		++a;
		//cout<<c<<endl;
		l+=(c-'a'+1)*basel;
		l1+=(c-'a'+1)*basel1;
		p=(p+(c-'a'+1))*base;
		p1=(p1+(c-'a'+1))*base1;
		basel*=base;
		basel1*=base1;
		mod(basel,m);
		mod(basel1,m1);
		mod(l,m);
		mod(l1,m1);
		mod(p,m);
		mod(p1,m1);
	//	cout<<l<<" "<<p<<"   "<<l1<<" "<<p1<<endl;
		/*if(!(a^8388608))
		{
			a=-69;
			break;
		}*/
	}
	/*
	if(a==-69)
	while((c=getchar_unlocked())!=EOF){
		//cout<<c<<endl;
		if(c==' ' || c=='\n')break;
		l+=(c-'a'+1)*basel;
		p=(p+(c-'a'+1))*base;
		basel*=base;
		mod(basel,m);
		mod(l,m);
		mod(p,m);
	}*/
	//cout<<l<<"_"<<p<<"___"<<l1<<"_"<<p1<<"__"<<a<<endl;
	if((a==-69 && l==p) || (l==p && l1==p1 && a!=-69))
	puts("TAK");
	else
	puts("NIE");
}