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
106
107
108
109
110
111
112
113
#include<iostream>

using namespace std;

bool tab[600000];

int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	char c;
	cin>>n;
	bool tf = 1;
	if(n != 0)
	{
		int i;
		for(i = 0; i < n/2; ++i)
		{
			cin>>c;
			i*=6;
			tab[i] = (c&1);
			c = c>>1;
			tab[i+1] = (c&1);
			c = c>>1;
			tab[i+2] = (c&1);
			c = c>>1;
			tab[i+3] = (c&1);
			c = c>>1;
			tab[i+4] = (c&1);
			c = c>>1;
			tab[i+5] = (c&1);
			i/=6;
		}
		if(n%2 ==1)
			cin>>c;
		--i;
		while(i>=0)
		{
			cin>>c;
			i*=6;
			if(tab[i] ^ (c&1))
				tf= 0;
			c = c>>1;
			if(tab[i+1] ^ (c&1))
				tf = 0;
			c = c>>1;
			if(tab[i+2] ^ (c&1))
				tf = 0;
			c = c>>1;
			if(tab[i+3] ^ (c&1))
				tf = 0;
			c = c>>1;
			if(tab[i+4] ^ (c&1))
				tf = 0;
			c = c>>1;
			if(tab[i+5] ^ (c&1))
				tf = 0;
			i/=6;	
			--i;
		}
	}
	else
	{
		int i = 0;
		while(cin>>c)
		{
			//cout<<c<<endl;
			++n;
			i*=6;
			tab[i] = (c&1);
			c = c>>1;
			tab[i+1] = (c&1);
			c = c>>1;
			tab[i+2] = (c&1);
			c = c>>1;
			tab[i+3] = (c&1);
			c = c>>1;
			tab[i+4] = (c&1);
			c = c>>1;
			tab[i+5] = (c&1);
			i/=6;
			++i;
		}
		//cout<<"ok"<<endl;
		for(i = 0; i < n/2; ++i)
		{
			i*=6;
			//cout<<i<<" "<<n-i-6<<"\n";
			if(tab[i] ^ (tab[n*6-i-6]))
				tf= 0;
			c = c>>1;
			if(tab[i+1] ^ (tab[n*6-i-5]))
				tf = 0;
			c = c>>1;
			if(tab[i+2] ^ (tab[n*6-i-4]))
				tf = 0;
			c = c>>1;
			if(tab[i+3] ^ (tab[n*6-i-3]))
				tf = 0;
			c = c>>1;
			if(tab[i+4] ^ (tab[n*6-i-2]))
				tf = 0;
			c = c>>1;
			if(tab[i+5] ^ (tab[n*6-i-1]))
				tf = 0;
			i/=6;
		}
	}
	if(tf)
		cout<<"TAK\n";
	else
		cout<<"NIE\n";
}