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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

typedef vector<char> stringvect;

bool IsPalindrome(const string& str)
{
	if (str.empty()) return false;

	int i = 0;                
	int j = str.length() - 1; 

	while (i < j)
	{
		if (str[i] != str[j])
			return false;
		i++;
		j--;
	}
	return true;
}

bool IsPalindromeVect(const stringvect& str)
{
	if (str.empty()) return false;

	int i = 0;
	int j = str.size() - 1;

	while (i < j)
	{
		if (str[i] != str[j])
			return false;
		i++;
		j--;
	}
	return true;
}
/*
uint32_t *buffer;

void set(const uint32_t offset, const uint32_t in)
{
	uint32_t* __restrict out;
	uint32_t startBit,bitsAvailable, mask;

	out = &buffer[((uint64_t)offset * (uint64_t)5) / 32];
	startBit = ((uint64_t)offset * (uint64_t)5) % 32;
	bitsAvailable = 32 - startBit;
	mask = (uint32_t)(1ULL << 5) - 1;

	if (5 <= bitsAvailable)
		out[0] = (out[0] & ~(mask << startBit)) | (in << startBit);
	else
	{
		uint32_t low, high;
		low = in << startBit;
		high = in >> bitsAvailable;
		out[0] = (out[0] & ~(mask << startBit)) | low;
		out[1] = (out[1] & ~(mask >> (32 - startBit))) | high;
	}
}

uint32_t get(const uint32_t offset)
{
	const uint32_t* __restrict in;
	uint32_t startBit,bitsAvailable,mask,out;

	in = &buffer[((uint64_t)offset * (uint64_t)5) / 32];
	startBit = ((uint64_t)offset * (uint64_t)5) % 32;
	bitsAvailable = 32 - startBit;

	mask = (uint32_t)(1ULL << 5) - 1;

	if (5 <= bitsAvailable)
		out = (in[0] >> startBit) & mask;
	else
	{
		uint32_t low, high;
		low = in[0] >> startBit;
		high = in[1] << (32 - startBit);
		out = low ^ ((low ^ high) & (mask >> bitsAvailable << bitsAvailable));
	}

	return out;
}
*/

int main()
{
/*	buffer = (uint32_t*)malloc(786000*sizeof(uint32_t));
	
	set(0, 'o'-'a');
	set(1, 'k'-'a');

	//cout << (char)(get(1)+'a') << (char)(get(0) + 'a');
	cout << "TAK";
	return 0;*/
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);

	bool isPalindromrV = false;
	int n;
  	cin >> n;
	//while (getchar() != '\n');

	stringvect input;


	if (n == 0) //nieznamy dlugosci, nie pozostaje nic innego jak wczytac calosc
	{
		string input;
		cin >> input;
		
		isPalindromrV = IsPalindrome(input);
	}
	else
	{//znamy dlugosc
		isPalindromrV = true;
		int half = n / 2;

		char c;
		cin.get(c);

		while (half-- > 0 && cin.get(c))
		{
			input.push_back(c);
		}

		//input zawiera piersza polowe
		//jesli dlugosc nieparzysta ignorujemy srodkowy znak
		if (n % 2 != 0)
			cin.get(c);

		
		half = (n/2) - 1;

		while (cin.get(c))
		{
			if (c == '\n') break;
			if (c != input[half])
			{
				isPalindromrV = false;
				break;
			}
			half--;
		}
	}

	if (isPalindromrV) cout << "TAK" << endl; else cout << "NIE" << endl;
	return 0;
}