Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half.

 [Image] English alphabet 

You are given a string s. Check if the string is "s-palindrome".


-----Input-----

The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.


-----Output-----

Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.


-----Examples-----
Input
oXoxoXo

Output
TAK

Input
bod

Output
TAK

Input
ER

Output
NIE

Difficulty: MEDIUM_HARD
Tags: String algorithms

Implementation

Starter code:

Solutions:
chars = {'A': {'A'}, 'b': {'d'}, 'd': {'b'}, 'H': {'H'}, 'M': {'M'}, 'O': {'O'}, 'o': {'o'}, 'T': {'T'}, 'U': {'U'}, 'V': {'V'}, 'v': {'v'}, 'W': {'W'}, 'w': {'w'}, 'X': {'X'}, 'x': {'x'}, 'Y': {'Y'}, 'q': {'p'}, 'p': {'q'}, 'I': {'I'}}
not_clean = {'p', 'q', 'b', 'd'}
s = input()
ans = True
for i in range(len(s) // 2):
	if s[i] not in chars.keys() or s[len(s) - i - 1] not in chars[s[i]]:
		ans = False
		break
if len(s) % 2 != 0 and (s[len(s) // 2] not in chars.keys() or s[len(s) // 2] in not_clean):
	ans = False
if ans:
	print('TAK')
else:
	print('NIE')


def palimdrom(text):
	for i in range(len(text)):
		if text[i] not in 'AHIMOoTUVvWwXxY':
			try:
				rules = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}
				if rules[text[i]] != text[-i - 1]:
					return 'NIE'
			except Exception:
				return 'NIE'
		elif text[i] != text[-i - 1]:
			return 'NIE'
	return 'TAK'
print(palimdrom(input()))


def calcut(x, etalon, dl, l, n, t):
	s = 0
	for i in range(n + t):
		if x[0][i] == x[0][l - 1 - i]:
			for y in range(dl):
				if x[0][i] == etalon[y]:
					s = s + 1
		elif x[0][i] == 'b' and x[0][l - 1 - i] == 'd' or (x[0][i] == 'd' and x[0][l - 1 - i] == 'b'):
			s = s + 1
		elif x[0][i] == 'p' and x[0][l - 1 - i] == 'q' or (x[0][i] == 'q' and x[0][l - 1 - i] == 'p'):
			s = s + 1
		else:
			print('NIE')
			break
	else:
		if s == n + t:
			print('TAK')
		else:
			print('NIE')
x = input().split()
etalon = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']
dl = len(etalon)
l = len(x[0])
n = l // 2
if n == 0:
	for y in range(dl):
		if x[0][0] == etalon[y]:
			print('TAK')
			break
		elif y + 1 == dl:
			print('NIE')
			break
elif l % 2 != 0:
	calcut(x, etalon, dl, l, n, 1)
else:
	calcut(x, etalon, dl, l, n, 0)


a = 'xXAHIMoOTUVvWwY'
d = {'bd', 'pq'}
s = input()
n = len(s)
res = True
for i in range(n):
	(x, y) = (s[i], s[n - i - 1])
	if x == y and x in a:
		continue
	if x + y in d or y + x in d:
		continue
	print('NIE')
	exit()
print('TAK')


import os
import sys
from io import BytesIO, IOBase
mod = 10 ** 9 + 7

def main():
	s = list(input())
	n = len(s)
	ans = 'TAK'
	l = n // 2
	r = n // 2 - 1 + n % 2
	while r < n:
		check = list(set([s[l], s[r]]))
		check.sort()
		if len(check) == 1:
			i = check[0]
			if i in 'AHIMOoTUVvWwXxY':
				pass
			else:
				ans = 'NIE'
				break
		elif check == ['b', 'd']:
			pass
		elif check == ['p', 'q']:
			pass
		else:
			ans = 'NIE'
			break
		l -= 1
		r += 1
	print(ans)

def nouse0():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse1():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse2():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def nouse3():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse4():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse5():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
main()


def r():
	return list(map(int, input().split()))
SYM_LETTERS = set('AHIMOoTUVvWwXxY')
mirror = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}
for letter in SYM_LETTERS:
	mirror[letter] = letter

def is_s_palindrome(s):
	if not s:
		return True
	if len(s) == 1:
		return s in SYM_LETTERS
	if s[0] not in mirror or s[-1] != mirror[s[0]]:
		return False
	return is_s_palindrome(s[1:-1])
print('TAK' if is_s_palindrome(input()) else 'NIE')


d = 'AHIMOoTUVvWwXxY'
s = input()
for i in range(len(s) // 2 + 1):
	if not (s[i] in d and s[i] == s[-i - 1]) and (not s[i] + s[-i - 1] in ['bd', 'db', 'pq', 'qp']):
		print('NIE')
		break
else:
	print('TAK')


rever = 'AHIMOTUVWXYovwx'
rev = ['bd', 'pq', 'db', 'qp']
line = input().rstrip()
if len(line) & 1 and line[len(line) // 2] not in rever:
	print('NIE')
	exit()
l = len(line) // 2 - 1
r = len(line) // 2 if len(line) & 1 == 0 else len(line) // 2 + 1
for i in range(len(line) // 2):
	if line[l] + line[r] not in rev and (line[l] not in rever or line[l] != line[r]):
		break
	l -= 1
	r += 1
if l != -1 or r != len(line):
	print('NIE')
else:
	print('TAK')


s = input()
n = len(s)
c = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']
p = ['b', 'd', 'q', 'p']
ok = 1
for i in range(n):
	if s[i] == s[n - i - 1] or (s[i] in p and s[n - i - 1] in p):
		continue
	ok = 0
if ok == 1:
	for i in range(n):
		if s[i] in c:
			continue
		elif s[i] in p:
			if s[i] == p[0] and s[n - i - 1] == p[1]:
				continue
			elif s[i] == p[1] and s[n - i - 1] == p[0]:
				continue
			elif s[i] == p[2] and s[n - i - 1] == p[3]:
				continue
			elif s[i] == p[3] and s[n - i - 1] == p[2]:
				continue
		ok = 0
if ok == 1:
	print('TAK')
else:
	print('NIE')


a = 'AHIMOTUVWXYovwx'
b = 'bdpq'
c = 'dbqp'
l = list(zip(a, a)) + list(zip(b, c))
s = input()

def f(c):
	for x in l:
		if c == x[0]:
			return x[1]
	return ' '
t = ''.join(map(f, s[::-1]))
print('TAK' if s == t else 'NIE')


s = input()
p = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'
for c in s:
	if c in p:
		print('NIE')
		exit()

def trans(c):
	d = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}
	if c in d:
		return d[c]
	return c
t = ''.join(map(trans, s[::-1]))
if t == s:
	print('TAK')
else:
	print('NIE')


d = {'o': 'o', 'I': 'I', 'H': 'H', 'b': 'd', 'x': 'x', 'X': 'X', 'V': 'V', 'v': 'v', 'U': 'U', 'W': 'W', 'w': 'w', 'M': 'M', 'A': 'A', 'Y': 'Y', 'T': 'T', 'p': 'q', 'q': 'p', 'd': 'b', 'O': 'O'}
c = ['U', 'I', 'O', 'T', 'H', 'X', 'x', 'o', 'M', 'A', 'W', 'w', 'V', 'v', 'Y']
s = input()
if len(s) % 2 == 0:
	n = len(s) // 2
	j = len(s) // 2 + 1
	i = 0
	while i < n:
		if s[i] not in d:
			print('NIE')
			exit()
		if d[s[i]] != s[len(s) - i - 1]:
			print('NIE')
			exit()
		i += 1
	print('TAK')
else:
	if s[len(s) // 2] not in c:
		print('NIE')
		exit()
	for i in range(len(s) // 2):
		if s[i] not in d:
			print('NIE')
			exit()
		if d[s[i]] != s[len(s) - i - 1]:
			print('NIE')
			exit()
	print('TAK')


s = input()
D = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}
for (c1, c2) in zip(s, s[::-1]):
	if D.get(c1, '') != c2:
		print('NIE')
		exit()
print('TAK')


import sys
s = input()
n = len(s)
m = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}
for i in range(0, n // 2):
	if not s[i] in m or s[n - 1 - i] != m[s[i]]:
		print('NIE')
		sys.exit()
if n % 2:
	i = n // 2
	if not s[i] in ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']:
		print('NIE')
		sys.exit()
print('TAK')


a = {'A': 'A', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'T': 'T', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'b': 'd', 'd': 'b', 'o': 'o', 'v': 'v', 'w': 'w', 'x': 'x', 'q': 'p', 'p': 'q'}
s = input().rstrip()
n = len(s)
ans = 'TAK'
for i in range(n // 2):
	if a.get(s[i]) == None or a[s[i]] != s[-(i + 1)]:
		ans = 'NIE'
		break
if n % 2 and (a.get(s[n // 2]) == None or a[s[n // 2]] != s[n // 2]):
	ans = 'NIE'
print(ans)


sym = 'AHIMOTUVWXYovwx'
mir = {'p': 'q', 'q': 'p', 'd': 'b', 'b': 'd'}

def good(a, b):
	if a in sym and a == b:
		return True
	if a in mir and mir[a] == b:
		return True
	return False

def check(s: str) -> bool:
	for i in range(len(s)):
		j = len(s) - i - 1
		if i == j:
			if not s[i] in sym:
				return False
		if i != j:
			if not good(s[i], s[j]):
				return False
	return True
s = input()
print('TAK' if check(s) else 'NIE')


def solution(s):
	t = 'AHIMOoTUVvWwXxY'
	pol = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}
	for i in range(len(s) // 2):
		if s[i] in pol:
			if s[len(s) - i - 1] != pol[s[i]]:
				return 'NIE'
		else:
			return 'NIE'
	if len(s) % 2:
		if s[len(s) // 2] in t:
			return 'TAK'
		else:
			return 'NIE'
	elif pol[s[len(s) // 2 - 1]] == s[len(s) // 2]:
		return 'TAK'
	else:
		return 'NIE'
print(solution(input()))


import sys

def main():
	s = stdin_get_string_from_first_line()
	mirrors = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']
	l = len(s)
	if l % 2 != 0 and s[int(l / 2)] not in mirrors:
		n()
	for i in range(0, int(l / 2)):
		j = l - i - 1
		if s[i] == s[j] and s[i] in mirrors:
			continue
		if s[i] == 'b' and s[j] == 'd':
			continue
		if s[i] == 'd' and s[j] == 'b':
			continue
		if s[i] == 'p' and s[j] == 'q':
			continue
		if s[i] == 'q' and s[j] == 'p':
			continue
		n()
	y()

def stdin_get_string_from_first_line():
	return sys.stdin.readline().strip()

def y():
	print('TAK')
	exit()

def n():
	print('NIE')
	exit()
main()


import sys
mirror = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}
s = input()
for (c1, c2) in zip(s, reversed(s)):
	if c1 not in mirror or mirror[c1] != c2:
		print('NIE')
		exit()
print('TAK')


d = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']
s = input()
l = 0
r = len(s) - 1
f = 1
while l <= r:
	if s[l] in d and s[r] in d and (s[l] == s[r]) or (s[l] == 'b' and s[r] == 'd') or (s[l] == 'd' and s[r] == 'b') or (s[l] == 'p' and s[r] == 'q') or (s[l] == 'q' and s[r] == 'p'):
		l += 1
		r -= 1
	else:
		f = 0
		break
if f:
	print('TAK')
else:
	print('NIE')


import sys, math
s = input()
pal = 'AHIMOoTUVvWwXxY'
n = len(s)
l = 0
r = n - 1
flag = True
fir = 'pq'
sec = 'bd'
while l <= r:
	if s[l] == s[r] and s[l] in pal:
		l += 1
		r -= 1
		continue
	elif s[l] == s[r]:
		flag = False
		break
	elif s[l] in fir and s[r] in fir:
		l += 1
		r -= 1
		continue
	elif s[l] in sec and s[r] in sec:
		l += 1
		r -= 1
		continue
	else:
		flag = False
		break
if flag:
	print('TAK')
else:
	print('NIE')


text = input()
symm = 'AHIMOoTUVvWwXxY'
middle = len(text) // 2 + 1
error = False
for i in range(middle):
	if text[i] in symm and text[i] == text[-1 - i] or text[i] + text[-i - 1] in ['bd', 'db', 'pq', 'qp']:
		continue
	else:
		print('NIE')
		error = True
		break
if not error:
	print('TAK')


s = input()
a = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'
b = 'AbdHIMOopqTUVvWwXxY'
c = 'AdbHIMOoqpTUVvWwXxY'
f = True
n = len(s)
for i in range(0, n):
	if s[i] in a:
		f = False
	elif c[b.index(s[i])] != s[n - i - 1]:
		f = False
	if f == False:
		break
print('TAK' if f else 'NIE')


a = 'AHIMOTUVWXYovwx'
b = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}
s = str(input())
ok = True
slen = len(s)
for i in range((slen - 1) // 2 + 1):
	if s[i] in a and s[i] == s[slen - i - 1] or (b.get(s[i], 0) and b[s[i]] == s[slen - 1 - i]):
		continue
	else:
		ok = False
		break
print(['NIE', 'TAK'][ok])


import re
string = str(input())
count = 0
s = ('A', 'O', 'W', 'Y', 'T', 'X', 'o', 'w', 'x', 'I', 'M', 'U', 'V', 'v', 'H')
for i in range(0, int(len(string) / 2)):
	if string[i] == string[len(string) - i - 1] and string[i] in s or (string[i] == 'b' and string[len(string) - i - 1] == 'd') or (string[i] == 'd' and string[len(string) - i - 1] == 'b') or (string[i] == 'p' and string[len(string) - i - 1] == 'q') or (string[i] == 'q' and string[len(string) - i - 1] == 'p'):
		count += 1
if len(string) % 2 == 1:
	if string[int(len(string) / 2)] not in s:
		count -= 1
if count == int(len(string) / 2):
	print('TAK')
else:
	print('NIE')


class CodeforcesTask691BSolution:

	def __init__(self):
		self.result = ''
		self.word = ''

	def read_input(self):
		self.word = input()

	def process_task(self):
		symetric_chars = [('A', 'A'), ('b', 'd'), ('I', 'I'), ('o', 'o'), ('O', 'O'), ('X', 'X'), ('x', 'x'), ('T', 'T'), ('Y', 'Y'), ('p', 'q'), ('W', 'W'), ('w', 'w'), ('V', 'V'), ('v', 'v'), ('U', 'U'), ('M', 'M'), ('H', 'H')]
		sc = list(set([x[0] for x in symetric_chars] + [x[1] for x in symetric_chars]))
		canbe = True
		for c in self.word:
			if c not in sc:
				canbe = False
				break
		if canbe:
			for x in range(len(self.word) // 2):
				c1 = self.word[x]
				c2 = self.word[-x - 1]
				canbe = False
				for pair in symetric_chars:
					if pair[0] == c1:
						if pair[1] != c2:
							canbe = False
							break
						else:
							canbe = True
							break
					elif pair[0] == c2:
						if pair[1] != c1:
							canbe = False
							break
						else:
							canbe = True
							break
				if not canbe:
					break
		if len(self.word) % 2:
			c = self.word[len(self.word) // 2]
			canbe = c in 'AIoOXxTYWwVvUMH' and canbe
		self.result = 'TAK' if canbe else 'NIE'

	def get_result(self):
		return self.result
Solution = CodeforcesTask691BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


__author__ = 'Alexander'
import sys
string = sys.stdin.readline().strip()
ideal = {'A', 'b', 'd', 'H', 'I', 'M', 'O', 'o', 'p', 'q', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}
for i in range(int((len(string) + 1) / 2)):
	if string[i] not in ideal:
		sys.stdout.write('NIE')
		sys.exit()
	elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or (string[i] == 'q'):
		if string[i] == 'b' and string[-i - 1] != 'd' or (string[i] == 'd' and string[-i - 1] != 'b') or (string[i] == 'q' and string[-i - 1] != 'p') or (string[i] == 'p' and string[-i - 1] != 'q'):
			sys.stdout.write('NIE')
			sys.exit()
	elif string[i] != string[-i - 1]:
		sys.stdout.write('NIE')
		sys.exit()
sys.stdout.write('TAK')


tak = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}
tok = 'AHIMOoTUVvWwXxY'
s = input()
le = len(s)
le2 = le // 2
if 1 == le & 1 and (not s[le2] in tok):
	print('NIE')
	return
s1 = s[0:le2]
s2 = s[le2 + (le & 1):][::-1]
for i in range(0, le2):
	if s1[i] == s2[i] and s1[i] in tok:
		continue
	if s1[i] in tak and tak[s1[i]] == s2[i]:
		continue
	print('NIE')
	return
print('TAK')


s = input()
n = len(s)
ans = 'TAK'
for i in range(int(n / 2)):
	j = n - i - 1
	if s[i] == 'b' and s[j] == 'd':
		continue
	elif s[i] == 'p' and s[j] == 'q':
		continue
	elif s[i] == 'd' and s[j] == 'b':
		continue
	elif s[i] == 'q' and s[j] == 'p':
		continue
	elif (s[i] == 'A' or s[i] == 'H' or s[i] == 'I' or (s[i] == 'M') or (s[i] == 'O') or (s[i] == 'o') or (s[i] == 'T') or (s[i] == 'U') or (s[i] == 'V') or (s[i] == 'v') or (s[i] == 'W') or (s[i] == 'w') or (s[i] == 'X') or (s[i] == 'x') or (s[i] == 'Y')) and s[i] == s[j]:
		continue
	else:
		ans = 'NIE'
		break
if ans == 'NIE':
	print(ans)
elif n % 2 == 0:
	print(ans)
else:
	i = int(n / 2)
	if s[i] == 'A' or s[i] == 'H' or s[i] == 'I' or (s[i] == 'M') or (s[i] == 'O') or (s[i] == 'o') or (s[i] == 'T') or (s[i] == 'U') or (s[i] == 'V') or (s[i] == 'v') or (s[i] == 'W') or (s[i] == 'w') or (s[i] == 'X') or (s[i] == 'x') or (s[i] == 'Y'):
		pass
	else:
		ans = 'NIE'
	print(ans)


import sys, os, io
from sys import stdin
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for _ in range(1):
	s = input()
	n = len(s)
	d = defaultdict(lambda : 0)
	d['b'] = 'd'
	d['d'] = 'b'
	d['o'] = 'o'
	d['p'] = 'q'
	d['q'] = 'p'
	d['v'] = 'v'
	d['w'] = 'w'
	d['x'] = 'x'
	d['A'] = 'A'
	d['H'] = 'H'
	d['I'] = 'I'
	d['M'] = 'M'
	d['O'] = 'O'
	d['T'] = 'T'
	d['U'] = 'U'
	d['V'] = 'V'
	d['W'] = 'W'
	d['X'] = 'X'
	d['Y'] = 'Y'
	if n % 2 == 1:
		j = i = n // 2
		if d[s[i]] == s[i]:
			i = i - 1
			j += 1
			while i >= 0:
				if d[s[i]] == s[j]:
					i -= 1
					j += 1
				else:
					print('NIE')
					exit(0)
			print('TAK')
		else:
			print('NIE')
			exit(0)
	else:
		j = i = n // 2
		i = i - 1
		while i >= 0:
			if d[s[i]] == s[j]:
				i -= 1
				j += 1
			else:
				print('NIE')
				exit(0)
		print('TAK')


def check(s):
	chars = 'AHIMOoTUVvWwXxY'
	sr = list(reversed(s))
	for i in range(len(s)):
		if s[i] not in chars + 'dbpq':
			return False
		if s[i] in chars and s[i] != sr[i]:
			return False
		for (a, b) in [('d', 'b'), ('b', 'd'), ('q', 'p'), ('p', 'q')]:
			if s[i] == a and sr[i] != b:
				return False
	return True
s = input()
if check(s):
	print('TAK')
else:
	print('NIE')


def main():
	s = input('')
	n = len(s)
	mir1 = 'ovwxAHIMOTUVWXY'
	mir2 = 'bdpq'
	mir = mir1 + mir2
	for i in range(n):
		if mir.count(s[i]) == 1:
			bit = 1
		else:
			bit = 0
			break
	if n == 1 and bit == 1:
		if mir1.count(s) == 1:
			print('TAK')
		else:
			print('NIE')
	elif n % 2 != 0 and bit == 1:
		p = n // 2
		sm = s[p]
		sf = s[0:p]
		sl = s[p + 1:]
		sl = sl.replace('b', '#')
		sl = sl.replace('d', 'b')
		sl = sl.replace('#', 'd')
		sl = sl.replace('p', '#')
		sl = sl.replace('q', 'p')
		sl = sl.replace('#', 'q')
		sf = sf[::-1]
		if sf == sl and mir1.count(sm) == 1:
			print('TAK')
		else:
			print('NIE')
	elif n % 2 == 0 and bit == 1:
		p = n // 2
		sf = s[0:p]
		sl = s[p:]
		sl = sl.replace('b', '#')
		sl = sl.replace('d', 'b')
		sl = sl.replace('#', 'd')
		sl = sl.replace('p', '#')
		sl = sl.replace('q', 'p')
		sl = sl.replace('#', 'q')
		sf = sf[::-1]
		if sf == sl:
			print('TAK')
		else:
			print('NIE')
	else:
		print('NIE')
main()


d = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'X': 'X', 'x': 'x', 'Y': 'Y', 'W': 'W', 'V': 'V', 'w': 'w', 'v': 'v', 'T': 'T', 'p': 'q', 'q': 'p', 'U': 'U'}
g = lambda c: '*' if c not in list(d.keys()) else d[c]
s = input()
for i in range(len(s)):
	if s[i] != g(s[len(s) - i - 1]):
		print('NIE')
		return
print('TAK')


text = input()
if len(text) % 2 == 0:
	example = text[0:len(text) // 2]
	ex = text[len(text) // 2:]
else:
	example = text[0:len(text) // 2 + 1]
	ex = text[len(text) // 2:]
ex = ex[::-1]
ex2 = ''
for i in ex:
	p = ['o', 'v', 'w', 'x', 'A', 'H', 'I', 'M', 'O', 'T', 'U', 'V', 'W', 'X', 'Y']
	if i == 'b':
		ex2 += 'd'
	elif i == 'd':
		ex2 += 'b'
	elif i == 'p':
		ex2 += 'q'
	elif i == 'q':
		ex2 += 'p'
	elif p.count(i) == 1:
		ex2 += i
	else:
		ex2 += '0'
if example == ex2:
	print('TAK')
else:
	print('NIE')


import sys
input = sys.stdin.readline
s = input().rstrip()
mid = len(s) // 2
l1 = list('AHIMOoTUVvWwXxY')
flag = True
if len(s) % 2 == 1:
	if not s[mid] in l1:
		flag = False
	i = 1
	while mid - i >= 0 and mid + i < len(s):
		if s[mid - i] != s[mid + i]:
			if s[mid - i] == 'p' and s[mid + i] == 'q' or (s[mid - i] == 'q' and s[mid + i] == 'p'):
				i += 1
				continue
			elif s[mid - i] == 'b' and s[mid + i] == 'd' or (s[mid - i] == 'd' and s[mid + i] == 'b'):
				i += 1
				continue
			else:
				flag = False
				break
		elif not s[mid - i] in l1:
			flag = False
			break
		i += 1
else:
	i = 1
	while mid - i >= 0 and mid + i - 1 < len(s):
		if s[mid - i] != s[mid + i - 1]:
			if s[mid - i] == 'p' and s[mid + i - 1] == 'q' or (s[mid - i] == 'q' and s[mid + i - 1] == 'p'):
				i += 1
				continue
			elif s[mid - i] == 'b' and s[mid + i - 1] == 'd' or (s[mid - i] == 'd' and s[mid + i - 1] == 'b'):
				i += 1
				continue
			else:
				flag = False
				break
		elif not s[mid - i] in l1:
			flag = False
			break
		i += 1
if flag:
	print('TAK')
else:
	print('NIE')


def check(string):
	first = string[:len(string) // 2]
	second = string[len(string) // 2:]
	second.reverse()
	for i in range(0, len(first)):
		if first[i] != second[i]:
			if first[i] == 'b':
				if second[i] == 'd':
					pass
				else:
					print('NIE')
					return 1
			elif first[i] == 'd':
				if second[i] == 'b':
					pass
				else:
					print('NIE')
					return 1
			elif first[i] == 'p':
				if second[i] == 'q':
					pass
				else:
					print('NIE')
					return 1
			elif first[i] == 'q':
				if second[i] == 'p':
					pass
				else:
					print('NIE')
					return 1
			else:
				print('NIE')
				return 1
		elif first[i] in set:
			pass
		else:
			print('NIE')
			return 1
	print('TAK')
	return 0
data = input()
string = []
for letter in data:
	string.append(letter)
set = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']
if len(string) % 2 != 0:
	if string[len(string) // 2] in set:
		string.pop(len(string) // 2)
		check(string)
	else:
		print('NIE')
else:
	check(string)


def main():
	non_symetrical = {'b', 'd', 'p', 'q'}
	chars = {'A': 'A', 'H': 'H', 'b': 'd', 'd': 'b', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}
	alpha = set(chars.keys())
	s = input()
	n = len(s)
	if n % 2 == 1:
		middle = s[n // 2]
		if middle not in alpha or middle in non_symetrical:
			print('NIE')
			return
	for i in range(n // 2 + 1):
		(first, last) = (s[i], s[n - i - 1])
		if first not in alpha or last not in alpha:
			print('NIE')
			return
		if chars[first] != last:
			print('NIE')
			return
	print('TAK')
main()


def f(a, b):
	kentuky = a + b in ('pq', 'qp', 'bd', 'db')
	yo_bro = a == b and a in 'AHIMOoTUVvWwXxY'
	return kentuky or yo_bro
s = input()
n = len(s)
for i in range(n):
	if not f(s[i], s[n - i - 1]):
		print('NIE')
		break
else:
	print('TAK')


sl = 'AHIMOoTUVvWwXxY'
s = input()
n = len(s)
for i in range((n + 1) // 2):
	(a, b) = (s[i], s[n - i - 1])
	if a == b and a in sl:
		continue
	elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:
		continue
	else:
		print('NIE')
		return
print('TAK')


def main():
	s = input()
	spal = True
	ss = ''
	for (i, c) in enumerate(s[::-1]):
		if c in 'WTYUIOAHXVMwoxv':
			ss += c
		elif c in 'qdbp':
			ss += 'qdbp'[3 - 'qdbp'.index(c)]
		else:
			spal = False
			break
	if s != ss:
		spal = False
	print('TAK' if spal else 'NIE')
main()


def main():
	s = input()
	print(solver(s))

def solver(s):
	mirrors = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}
	for i in range((len(s) + 1) // 2):
		left = s[i]
		right = s[len(s) - i - 1]
		if left not in mirrors or right != mirrors[left]:
			return 'NIE'
	return 'TAK'
main()


s = input()
d = {}
d['A'] = 'A'
d['b'] = 'd'
d['d'] = 'b'
d['H'] = 'H'
d['I'] = 'I'
d['o'] = 'o'
d['O'] = 'O'
d['p'] = 'q'
d['q'] = 'p'
d['v'] = 'v'
d['V'] = 'V'
d['M'] = 'M'
d['w'] = 'w'
d['W'] = 'W'
d['x'] = 'x'
d['X'] = 'X'
d['Y'] = 'Y'
d['T'] = 'T'
d['U'] = 'U'
n = len(s)
q = set(['o', 'O', 'A', 'x', 'X', 'Y', 'H', 'I', 'M', 'T', 'U', 'V', 'v', 'W', 'w'])
for i in range(n // 2):
	if d.get(s[i]):
		if d[s[i]] != s[n - 1 - i]:
			print('NIE')
			exit()
	else:
		print('NIE')
		exit()
if n % 2 == 1 and s[n // 2] not in q:
	print('NIE')
	exit()
print('TAK')


import re
import sys
exit = sys.exit
from bisect import bisect_left as bsl, bisect_right as bsr
from collections import Counter, defaultdict as ddict, deque
from functools import lru_cache
cache = lru_cache(None)
from heapq import *
from itertools import *
from math import inf
from pprint import pprint as pp
enum = enumerate
ri = lambda : int(rln())
ris = lambda : list(map(int, rfs()))
rln = sys.stdin.readline
rl = lambda : rln().rstrip('\n')
rfs = lambda : rln().split()
cat = ''.join
catn = '\n'.join
mod = 1000000007
d4 = [(0, -1), (1, 0), (0, 1), (-1, 0)]
d8 = [(-1, -1), (0, -1), (1, -1), (-1, 0), (1, 0), (-1, 1), (0, 1), (1, 1)]
a = {*'AHIMOoTUVvWwXxY'}
b = dict('bd db pq qp'.split())

def solve(s):
	n = len(s)
	if n % 2 and s[n // 2] not in a:
		return 0
	for i in range(n // 2):
		if s[i] == s[~i]:
			if s[i] not in a:
				return 0
		elif b.get(s[i], '') != s[~i]:
			return 0
	return 1
s = rl()
if solve(s):
	print('TAK')
else:
	print('NIE')


import sys
import bisect
from bisect import bisect_left as lb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
sflo = lambda : list(map(float, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
mod1 = 998244353
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)
ans = 0

def hnbhai(tc):
	s = 'AHIMOoTUVvWwXxY'
	op = ['bd', 'pq', 'qp', 'db']
	a = sa()
	for i in range(len(a) // 2 + 1):
		if not (a[i] in s and a[i] == a[-1 - i] or a[i] + a[-1 - i] in op):
			print('NIE')
			return
	print('TAK')
for _ in range(1):
	hnbhai(_ + 1)


sym = 'AHIMOoTUVvWwXxY'
rev = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}
S = input()
N = len(S)
ok = True
for i in range(N // 2):
	o = S[N - i - 1]
	ok &= S[i] in sym and S[i] == o or (S[i] in rev and rev[S[i]] == o)
if N & 1:
	ok &= S[N // 2] in sym
print('TAK' if ok else 'NIE')


import re
s = input().strip()
t = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)
m = {}
for i in range(ord('A'), ord('z') + 1):
	m[chr(i)] = chr(i)
m['b'] = 'd'
m['d'] = 'b'
m['p'] = 'q'
m['q'] = 'p'

def is_sp():
	sl = len(t)
	for i in range(sl // 2 + 1):
		if m[t[i]] != t[sl - 1 - i]:
			return False
	return True
if len(t) == len(s):
	if is_sp():
		print('TAK')
	else:
		print('NIE')
else:
	print('NIE')


def f(s):
	i = 0
	n = len(s)
	j = int(n) - 1
	S = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}
	while i <= j:
		if s[i] == 'b' and s[j] == 'd' or (s[i] == 'd' and s[j] == 'b'):
			i += 1
			j -= 1
			continue
		if s[i] == 'p' and s[j] == 'q' or (s[i] == 'q' and s[j] == 'p'):
			i += 1
			j -= 1
			continue
		if s[i] != s[j] or s[i] not in S or s[j] not in S:
			return False
		i += 1
		j -= 1
	return True
s = input()
if f(s):
	print('TAK')
else:
	print('NIE')


s = input()
selfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']
opps = {'b': 'd', 'p': 'q', 'd': 'b', 'q': 'p'}
for i in range(int(len(s) / 2) + 1):
	if s[i] not in selfs:
		if s[i] in opps.keys():
			if opps[s[i]] == s[len(s) - i - 1]:
				pass
			else:
				print('NIE')
				return
		else:
			print('NIE')
			return
	elif s[i] != s[len(s) - i - 1]:
		print('NIE')
		return
if len(s) % 2 == 1:
	if s[int(len(s) / 2)] not in selfs:
		print('NIE')
		return
print('TAK')


s = input()
mirror_letters = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']
mirror_d = {}
for char in mirror_letters:
	mirror_d[char] = char
mirror_d['b'] = 'd'
mirror_d['d'] = 'b'
mirror_d['p'] = 'q'
mirror_d['q'] = 'p'
flag = 1
n = len(s)
for i in range((n + 1) // 2):
	if s[i] in mirror_d and s[n - 1 - i] == mirror_d[s[i]]:
		continue
	else:
		flag = 0
		break
if flag:
	print('TAK')
else:
	print('NIE')


z = 'AHIMOoTUVvWwXxY'
t = [('b', 'd'), ('q', 'p')]
d = {}
for (i, j) in t:
	d[i] = j
	d[j] = i
for i in z:
	d[i] = i
s = input()
n = len(s)
a = 'TAK'
if n % 2 and s[n // 2] not in z:
	a = 'NIE'
for i in range(n // 2):
	if d.get(s[i], 0) != s[n - 1 - i]:
		a = 'NIE'
print(a)


s = str(input())
n = len(s)
ss = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']
ss2 = [('d', 'b'), ('q', 'p'), ('p', 'q'), ('b', 'd')]
for i in range(0, n // 2):
	if s[i] == s[n - 1 - i]:
		if not s[i] in ss:
			print('NIE')
			return
	elif not (s[i], s[n - 1 - i]) in ss2:
		print('NIE')
		return
if n % 2 != 0:
	if s[n // 2] in ss:
		print('TAK')
	else:
		print('NIE')
else:
	print('TAK')


selfsym = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']
opsym = {'b': 'd', 'p': 'q', 'd': 'b', 'q': 'p'}
(s, flag) = (input(), True)
for i in range(int(len(s) / 2) + 1):
	if s[i] not in selfsym:
		if s[i] in opsym.keys():
			if opsym[s[i]] != s[len(s) - i - 1]:
				flag = False
		else:
			flag = False
	elif s[i] != s[len(s) - i - 1]:
		flag = False
if len(s) % 2 == 1:
	if s[int(len(s) / 2)] not in selfsym:
		flag = False
print('TAK' if flag else 'NIE')


d = {}
d['A'] = 'A'
d['X'] = 'X'
d['W'] = 'W'
d['Y'] = 'Y'
d['O'] = 'O'
d['I'] = 'I'
d['M'] = 'M'
(d['T'], d['U'], d['V'], d['H']) = ('T', 'U', 'V', 'H')
(d['o'], d['v'], d['w'], d['x'], d['q'], d['p'], d['d'], d['b']) = ('o', 'v', 'w', 'x', 'p', 'q', 'b', 'd')
s = input()
if len(s) == 1:
	x = s[0]
	y = ['A', 'H', 'O', 'X', 'W', 'V', 'U', 'I', 'T', 'Y', 'o', 'x', 'v', 'w']
	if x in y:
		print('TAK')
	else:
		print('NIE')
	exit(0)
j = len(s) // 2
k = len(s) - 1
(i, flag) = (0, True)
while i <= j:
	try:
		x = d[s[i]]
		y = s[k]
		if x != y:
			flag = False
			break
		i += 1
		k -= 1
	except:
		print('NIE')
		exit(0)
if flag:
	print('TAK')
else:
	print('NIE')


t = input()
k = len(t) // 2 + 1
p = zip(t[:k], t[-k:][::-1])
(u, v) = ('AHIMOoTUVvWwXxY', 'bd db pq qp')
s = all((a in u and a == b or a + b in v for (a, b) in p))
print(['NIE', 'TAK'][s])


insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))
disym = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}
for c in insym:
	disym[c] = c
s = input()
n = len(s)
if n % 2 == 0 or s[n // 2] in insym:
	s1 = s[0:n // 2]
	s2 = s[::-1][0:n // 2]
	flg = True
	for i in range(n // 2):
		if s1[i] not in disym or disym[s1[i]] != s2[i]:
			flg = False
	if flg:
		print('TAK')
	else:
		print('NIE')
else:
	print('NIE')


A = input()
sym = 'AHIMOoTUVvWwXxYpqbd'
opposite = 'AHIMOoTUVvWwXxYqpdb'
ok = True
for i in range(len(A)):
	index = sym.find(A[i])
	if index >= 0 and A[-i - 1] == opposite[index]:
		pass
	else:
		ok = False
		break
print('TAK') if ok == True else print('NIE')


word = input()
l = len(word)
hasmid = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']
reflections = [('b', 'd'), ('d', 'b'), ('q', 'p'), ('p', 'q')]
if l % 2 == 1:
	if word[int((l - 1) / 2)] in hasmid:
		for i in range(l):
			if i != (l - 1) / 2:
				if word[i] in hasmid:
					if word[l - i - 1] in hasmid:
						if word[i] == word[l - i - 1]:
							continue
						else:
							print('NIE')
							exit()
					else:
						print('NIE')
						exit()
				else:
					refl = False
					for pair in reflections:
						if word[i] == pair[0]:
							if word[l - i - 1] == pair[1]:
								refl = True
								break
					if refl:
						continue
					else:
						print('NIE')
						exit()
	else:
		print('NIE')
		exit()
else:
	for i in range(l):
		if word[i] in hasmid:
			if word[l - i - 1] in hasmid:
				if word[i] == word[l - i - 1]:
					continue
				else:
					print('NIE')
					exit()
			else:
				print('NIE')
				exit()
		else:
			refl = False
			for pair in reflections:
				if word[i] == pair[0]:
					if word[l - i - 1] == pair[1]:
						refl = True
						break
			if refl:
				continue
			else:
				print('NIE')
				exit()
print('TAK')


s = input()
rs = list(s[::-1])
(b, d, p, q, c) = ('b', 'd', 'p', 'q', 0)
for i in range(len(rs)):
	if rs[i] == b:
		rs[i] = rs[i].replace(b, d)
	elif rs[i] == d:
		rs[i] = rs[i].replace(d, b)
	elif rs[i] == p:
		rs[i] = rs[i].replace(p, q)
	elif rs[i] == q:
		rs[i] = rs[i].replace(q, p)
rs = ''.join(rs)
if rs == s:
	for i in rs:
		if i == 'A' or i == 'H' or i == 'I' or (i == 'O') or (i == 'T') or (i == 'V') or (i == 'W') or (i == 'X') or (i == 'Y') or (i == 'M') or (i == 'U'):
			c += 1
		elif i == 'b' or i == 'd' or i == 'p' or (i == 'q') or (i == 'x') or (i == 'w') or (i == 'v') or (i == 'o'):
			c += 1
if c == len(s):
	print('TAK')
else:
	print('NIE')


from sys import exit
sym = [('A', 'A'), ('H', 'H'), ('I', 'I'), ('M', 'M'), ('O', 'O'), ('T', 'T'), ('U', 'U'), ('V', 'V'), ('W', 'W'), ('X', 'X'), ('Y', 'Y'), ('b', 'd'), ('o', 'o'), ('p', 'q'), ('v', 'v'), ('w', 'w'), ('x', 'x')]
half_sym = ['A', 'H', 'I', 'M', 'O', 'T', 'U', 'V', 'W', 'X', 'Y', 'o', 'v', 'w', 'x']
d = {}
for t in sym:
	(a, b) = t
	(d[a], d[b]) = (b, a)
s = input()
if len(s) % 2 == 1:
	c = len(s) // 2
	if s[c] not in half_sym:
		print('NIE')
		exit(0)
	l = c - 1
	r = c + 1
else:
	r = len(s) // 2
	l = r - 1
while l >= 0:
	if s[l] not in d or d[s[l]] != s[r]:
		print('NIE')
		exit(0)
	l -= 1
	r += 1
print('TAK')


s = input()
itself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}
d = {'p': 'q', 'q': 'p', 'b': 'd', 'd': 'b'}
for i in itself:
	d[i] = i
ok = True
for i in range(len(s)):
	ok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]
print('TAK' if ok else 'NIE')


def main():
	s = input()
	n = len(s)
	i = 0
	j = n - 1
	ans = 0
	while i < n / 2:
		if s[i] == s[j] and (s[i] == 'A' or s[i] == 'H' or s[i] == 'I' or (s[i] == 'M') or (s[i] == 'O') or (s[i] == 'T') or (s[i] == 'U') or (s[i] == 'V') or (s[i] == 'W') or (s[i] == 'X') or (s[i] == 'Y') or (s[i] == 'o') or (s[i] == 'v') or (s[i] == 'w') or (s[i] == 'x')):
			i += 1
			j -= 1
			continue
		elif s[i] != s[j] and (s[i] == 'p' and s[j] == 'q' or (s[i] == 'b' and s[j] == 'd') or (s[i] == 'd' and s[j] == 'b') or (s[i] == 'q' and s[j] == 'p')):
			i += 1
			j -= 1
			continue
		else:
			ans = 1
		i += 1
		j -= 1
	if ans:
		print('NIE')
	else:
		print('TAK')
main()


midsym = 'AHIMOoTUVvWwXxY'
sym = 'pqbd'
s = input()
if len(s) % 2 == 1:
	t = len(s) // 2
	if s[t] not in midsym:
		print('NIE')
		exit()
	s = s[:t] + s[t + 1:]
f = s[:int(len(s) / 2)]
l = s[int(len(s) / 2):]
l = l[::-1]
for k in range(len(f)):
	if f[k] not in midsym and f[k] not in sym:
		print('NIE')
		exit()
	if f[k] in midsym:
		if l[k] != f[k]:
			print('NIE')
			exit()
	if f[k] in sym:
		if f[k] == 'p' and l[k] == 'q':
			continue
		if f[k] == 'q' and l[k] == 'p':
			continue
		if f[k] == 'b' and l[k] == 'd':
			continue
		if f[k] == 'd' and l[k] == 'b':
			continue
		print('NIE')
		exit()
print('TAK')


import sys
pairs = ['AA', 'HH', 'II', 'MM', 'OO', 'TT', 'UU', 'VV', 'WW', 'XX', 'YY', 'bd', 'db', 'oo', 'pq', 'qp', 'vv', 'ww', 'xx']
s = input()
(l, r) = (0, len(s) - 1)
while l <= r:
	if s[l] + s[r] not in pairs:
		print('NIE')
		sys.exit(0)
	l += 1
	r -= 1
print('TAK')


m = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']
n = {'p': 'q', 'q': 'p', 'b': 'd', 'd': 'b'}
a = True
x = input()
for i in range(len(x) // 2):
	if x[i] in m:
		if x[-1 - i] != x[i]:
			a = False
			break
	elif x[i] in ['b', 'd', 'q', 'p']:
		if n[x[i]] != x[-1 - i]:
			a = False
			break
	else:
		a = False
		break
if len(x) % 2 == 1 and x[len(x) // 2] not in m:
	a = False
if a:
	print('TAK')
else:
	print('NIE')


s = input()
n = len(s) + 1
sym = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']
prs = [('b', 'd'), ('d', 'b'), ('p', 'q'), ('q', 'p')]
for i in range(n // 2):
	if s[i] in sym:
		if s[i] != s[-i - 1]:
			print('NIE')
			exit()
	elif (s[i], s[-i - 1]) not in prs:
		print('NIE')
		exit()
print('TAK')


s = input()
n = len(s)
pair = {'a': -1, 'A': 'A', 'b': 'd', 'B': -1, 'c': -1, 'C': -1, 'd': 'b', 'D': -1, 'e': -1, 'E': -1, 'f': -1, 'F': -1, 'g': -1, 'G': -1, 'h': -1, 'H': 'H', 'i': -1, 'I': 'I', 'j': -1, 'J': -1, 'k': -1, 'K': -1, 'l': -1, 'L': -1, 'm': -1, 'M': 'M', 'n': -1, 'N': -1, 'o': 'o', 'O': 'O', 'p': 'q', 'P': -1, 'q': 'p', 'Q': -1, 'r': -1, 'R': -1, 's': -1, 'S': -1, 't': -1, 'T': 'T', 'u': -1, 'U': 'U', 'v': 'v', 'V': 'V', 'w': 'w', 'W': 'W', 'x': 'x', 'X': 'X', 'y': -1, 'Y': 'Y', 'z': -1, 'Z': -1}
ans = 'TAK'
for i in range((n - 1) // 2 + 1):
	if pair[s[i]] != s[n - 1 - i]:
		ans = 'NIE'
		break
print(ans)


fine = 'AHIMOoTUVvWwXxY'
s = input()
for i in range(len(s) // 2 + 1):
	if not (s[i] in fine and s[i] == s[-i - 1] or s[i] + s[-i - 1] in ['pq', 'qp', 'bd', 'db']):
		print('NIE')
		exit()
print('TAK')


s = input()
good = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']
for i in range(len(s) // 2):
	if s[i] == s[len(s) - i - 1] and s[i] in good or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):
		pass
	else:
		print('NIE')
		exit()
if len(s) % 2 == 1:
	if s[len(s) // 2] in good:
		print('TAK')
	else:
		print('NIE')
else:
	print('TAK')


m = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}
a = 'AHIMOTUVWXYovwx'
f = lambda c: m[c] if c in m.keys() else c if a.count(c) else '#'
s = input()
for i in range(len(s)):
	if s[i] != f(s[len(s) - i - 1]):
		print('NIE')
		exit(0)
print('TAK')


s = input()
symmetric = 'AHIMOoTUVvWwXxY'
symmetric_pair = 'bdb pqp'
len_s = len(s)
half_len = len_s // 2
if len_s % 2 == 1:
	if s[half_len] not in symmetric:
		print('NIE')
		exit()
for i in range(half_len):
	cur = s[i]
	cur_opposite = s[~i]
	if cur != cur_opposite:
		if cur + cur_opposite not in symmetric_pair:
			print('NIE')
			exit()
	elif cur not in symmetric:
		print('NIE')
		exit()
print('TAK')


lst = ['AA', 'HH', 'II', 'MM', 'OO', 'TT', 'UU', 'VV', 'WW', 'XX', 'YY', 'bd', 'db', 'oo', 'pq', 'qp', 'vv', 'ww', 'xx']

def palindrom(s):
	(l, r) = (0, len(s) - 1)
	while l <= r:
		if s[l] + s[r] not in lst:
			return 'NIE'
		l += 1
		r -= 1
	return 'TAK'
print(palindrom(input()))


s = input()
sym = 'AHIMOoTUVvWwXxY'
mir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}
ans = True
l = len(s)
if l % 2 != 0 and s[l // 2] not in sym:
	ans = False
else:
	for i in range(l // 2):
		if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or (s[i] in sym and s[i] == s[l - i - 1])):
			ans = False
			break
print('TAK' if ans else 'NIE')


def main():
	s = input()
	for (a, b) in zip(s, s[::-1]):
		if a != {'A': 'A', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'T': 'T', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'b': 'd', 'd': 'b', 'o': 'o', 'p': 'q', 'q': 'p', 'v': 'v', 'w': 'w', 'x': 'x'}.get(b):
			print('NIE')
			break
	else:
		print('TAK')
main()


s = str(input())
n = len(s)
sym = 'AHIMOoTUVvWwXxY'
if n % 2 and sym.count(s[n // 2]) == 0:
	print('NIE')
else:
	r = ''
	ok = 1
	for i in range(n // 2):
		if sym.count(s[i]):
			r = s[i] + r
		elif s[i] == 'b':
			r = 'd' + r
		elif s[i] == 'd':
			r = 'b' + r
		elif s[i] == 'p':
			r = 'q' + r
		elif s[i] == 'q':
			r = 'p' + r
		else:
			ok = 0
			break
	if ok == 0:
		print('NIE')
	elif s[n // 2 + n % 2:] == r:
		print('TAK')
	else:
		print('NIE')


from string import ascii_lowercase as lowercase
from string import ascii_uppercase as uppercase
selfSym = 'AHIMOoTUVvWwXxY'
pair = {a: b for (a, b) in zip('bdpq', 'dbqp')}

def mirror(a, b):
	if a == b:
		return a in selfSym
	return a in pair and pair[a] == b
s = input().strip()
z = s[::-1]
for (a, b) in zip(s, z):
	if not mirror(a, b):
		print('NIE')
		exit(0)
print('TAK')


s = input()
h = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'v', 'V', 'W', 'w', 'X', 'x', 'Y']
q = ['A', 'b', 'd', 'H', 'I', 'M', 'O', 'o', 'p', 'q', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']
w = ['A', 'd', 'b', 'H', 'I', 'M', 'O', 'o', 'q', 'p', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']
g = False
if len(s) % 2:
	x = s[(len(s) + 1) // 2:]
	z = s[:(len(s) - 1) // 2]
	a = s[(len(s) - 1) // 2]
	z = list(reversed(z))
	if a not in h:
		g = True
	for i in range(len(z)):
		if g:
			break
		if x[i] not in q:
			g = True
			break
		if w[q.index(x[i])] != z[i]:
			g = True
	if g:
		print('NIE')
	else:
		print('TAK')
else:
	x = s[len(s) // 2:]
	z = s[:len(s) // 2]
	z = list(reversed(z))
	for i in range(len(z)):
		if g:
			break
		if x[i] not in q:
			g = True
			break
		if w[q.index(x[i])] != z[i]:
			g = True
	if g:
		print('NIE')
	else:
		print('TAK')


s = input()
l = len(s)
li = ['A', 'O', 'o', 'H', 'V', 'v', 'X', 'x', 'W', 'w', 'M', 'T', 'I', 'U', 'Y']
li1 = ['pq', 'qp', 'bd', 'db']
if l & 1:
	if s[l // 2] not in li:
		print('NIE')
		exit()
f = 0
for i in range(len(s) // 2):
	if s[i] == s[l - 1 - i]:
		if s[i] not in li:
			f = 1
			break
	elif s[i] + s[l - 1 - i] not in li1:
		f = 1
		break
if f:
	print('NIE')
else:
	print('TAK')


from string import ascii_letters
mirror_symmetry = 'AHIMOoTUVvWwXxY'
symmetric_to = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}
others = set(ascii_letters) - set(mirror_symmetry + 'bdpq')
string = input()

def f(s):
	if set(s) & others:
		return 'NIE'
	if len(s) % 2 == 1:
		if s[len(s) // 2] not in mirror_symmetry:
			return 'NIE'
		s = s[:len(s) // 2] + s[len(s) // 2 + 1:]
	for i in range(len(s) // 2):
		if s[i] in mirror_symmetry and s[-1 - i] == s[i]:
			continue
		if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:
			continue
		return 'NIE'
	return 'TAK'
print(f(string))


self_sym_list = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']
sym_dict = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}
sym_dict.update({k: k for k in self_sym_list})
sym_list = self_sym_list + list(sym_dict.keys())
ans = True
ind = 0
s = input()
if len(s) % 2 == 1:
	ind = len(s) // 2
	if s[ind] not in self_sym_list:
		ans = False
	ind -= 1
else:
	ind = len(s) // 2 - 1
for i in range(ind + 1):
	if s[i] not in sym_dict or sym_dict[s[i]] != s[len(s) - 1 - i]:
		ans = False
		break
if ans:
	print('TAK')
else:
	print('NIE')


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def check(a, b):
	ch = 0
	if a == 'b' and b == 'd':
		ch = 1
	elif a == 'd' and b == 'b':
		ch = 1
	elif a == 'o' and b == 'o':
		ch = 1
	elif a == 'p' and b == 'q':
		ch = 1
	elif a == 'q' and b == 'p':
		ch = 1
	elif a == 'v' and b == 'v':
		ch = 1
	elif a == 'w' and b == 'w':
		ch = 1
	elif a == 'x' and b == 'x':
		ch = 1
	elif a == 'A' and b == 'A':
		ch = 1
	elif a == 'H' and b == 'H':
		ch = 1
	elif a == 'I' and b == 'I':
		ch = 1
	elif a == 'M' and b == 'M':
		ch = 1
	elif a == 'O' and b == 'O':
		ch = 1
	elif a == 'T' and b == 'T':
		ch = 1
	elif a == 'U' and b == 'U':
		ch = 1
	elif a == 'V' and b == 'V':
		ch = 1
	elif a == 'W' and b == 'W':
		ch = 1
	elif a == 'X' and b == 'X':
		ch = 1
	elif a == 'Y' and b == 'Y':
		ch = 1
	return ch
s = input()
n = len(s)
ch = 1
for i in range(n // 2):
	c = check(s[i], s[n - i - 1])
	if c == 0:
		ch = 0
		break
a = ['A', 'H', 'I', 'M', 'O', 'T', 'U', 'V', 'W', 'X', 'Y', 'o', 'v', 'w', 'x']
if n % 2 == 1:
	if s[n // 2] not in a:
		ch = 0
if ch == 1:
	print('TAK')
else:
	print('NIE')


symmetric_letters = ['A', 'H', 'I', 'M', 'O', 'o', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y', 'T']
letter_trans = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}
for letter in symmetric_letters:
	letter_trans[letter] = letter
word = input()
if all([x in letter_trans for x in word]) and list(word) == [letter_trans[x] for x in word[::-1]]:
	print('TAK')
else:
	print('NIE')


import bisect
from itertools import accumulate
import os
import sys
import math
from decimal import *
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def SieveOfEratosthenes(n):
	prime = []
	primes = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if primes[p] == True:
			prime.append(p)
			for i in range(p * p, n + 1, p):
				primes[i] = False
		p += 1
	return prime

def primefactors(n):
	fac = []
	while n % 2 == 0:
		fac.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 2):
		while n % i == 0:
			fac.append(i)
			n = n // i
	if n > 1:
		fac.append(n)
	return fac

def factors(n):
	fac = set()
	fac.add(1)
	fac.add(n)
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			fac.add(i)
			fac.add(n // i)
	return list(fac)
s = input()
f = 0
a = ['H', 'A', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'w', 'W', 'x', 'X', 'Y']
i = 0
j = len(s) - 1
while i <= j:
	if s[i] == 'd' and s[j] == 'b' or (s[i] == 'b' and s[j] == 'd'):
		i += 1
		j -= 1
	elif s[i] == 'p' and s[j] == 'q' or (s[i] == 'q' and s[j] == 'p'):
		i += 1
		j -= 1
	elif s[i] == s[j] and s[i] in a:
		i += 1
		j -= 1
	else:
		f = 1
		break
if f == 0:
	print('TAK')
else:
	print('NIE')


s = input()
n = len(s)
N = 0
if n % 2 == 0:
	N = n // 2
else:
	N = n // 2 + 1
flag = True

def check(l, r):
	same = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']
	if l == r and l in same:
		return True
	if l == 'b' and r == 'd':
		return True
	if l == 'd' and r == 'b':
		return True
	if l == 'p' and r == 'q':
		return True
	if l == 'q' and r == 'p':
		return True
	return False
for i in range(N):
	left = i
	right = n - 1 - i
	lc = s[left]
	rc = s[right]
	if not check(lc, rc):
		flag = False
if flag:
	print('TAK')
else:
	print('NIE')


a = input()
(i, j) = (0, len(a) - 1)
while j >= i and [a[i], a[j]] in [['A', 'A'], ['b', 'd'], ['d', 'b'], ['H', 'H'], ['I', 'I'], ['M', 'M'], ['O', 'O'], ['o', 'o'], ['p', 'q'], ['q', 'p'], ['T', 'T'], ['U', 'U'], ['V', 'V'], ['v', 'v'], ['W', 'W'], ['w', 'w'], ['X', 'X'], ['x', 'x'], ['Y', 'Y']]:
	i += 1
	j -= 1
print('TAK' if j < i else 'NIE')


s = input()
mirror = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}
while len(s) > 1:
	if s[0] in 'AoOIMHTUVvWwXxY':
		if s[0] == s[-1]:
			s = s[1:-1]
		else:
			break
	elif s[0] in mirror:
		if s[0] == mirror[s[-1]]:
			s = s[1:-1]
		else:
			break
	else:
		break
if len(s) == 0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s) == 1):
	print('TAK')
else:
	print('NIE')


[print('TAK' if [s[i] + s[-1 - i] in 'AA.HH.II.MM.OO.oo.TT.UU.VV.vv.WW.ww.XX.xx.YY.bd.db.pq.qp' for i in range(len(s))] == [True] * len(s) else 'NIE') for s in [input()]]


SLETTERS = (('A', 'A'), ('b', 'd'), ('H', 'H'), ('I', 'I'), ('M', 'M'), ('O', 'O'), ('o', 'o'), ('p', 'q'), ('T', 'T'), ('U', 'U'), ('V', 'V'), ('v', 'v'), ('W', 'W'), ('w', 'w'), ('X', 'X'), ('x', 'x'), ('Y', 'Y'))
LETTERS = 'AHIMOoTUVvWwXxY'
s = input()
n = len(s)
if n == 1:
	s_pal = 'TAK' if s in LETTERS else 'NIE'
else:
	s_pal = 'TAK'
	for i in range(n // 2):
		if (s[i], s[n - i - 1]) not in SLETTERS and (s[n - i - 1], s[i]) not in SLETTERS:
			s_pal = 'NIE'
	if n % 2 == 1 and s[n // 2] not in LETTERS:
		s_pal = 'NIE'
print(s_pal)


s = input()
mir = 'xXAoOWwTYIMUvVH'

def ch(a, b, x):
	return s[x] == 'b' and s[-x - 1] == 'd' or (s[x] == 'p' and s[-x - 1] == 'q') or (s[x] == 'd' and s[-x - 1] == 'b') or (s[x] == 'q' and s[-x - 1] == 'p')

def ispal(s):
	flag = True
	for x in range(len(s) // 2):
		if (s[x] == s[-x - 1] and s[x] in mir or ch(s[x], s[-x - 1], x)) and (len(s) % 2 == 0 or s[len(s) // 2] in mir):
			pass
		else:
			flag = False
	return flag
if len(s) == 1 and s[0] in mir:
	print('TAK')
elif len(s) != 1 and ispal(s):
	print('TAK')
else:
	print('NIE')


def solution(s):
	allowed = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'q': 'p', 'p': 'q', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}
	i = 0
	j = len(s) - 1
	while i <= j:
		if not allowed.get(s[i]) or allowed.get(s[i]) != s[j]:
			return 'NIE'
		i += 1
		j -= 1
	return 'TAK'
print(solution(input()))


def check(s):
	p = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
	q = 'A      HI   M O    TUVWXY  d b          oqp    vwx  '
	for i in range(len(s)):
		if q[p.find(s[i])] != s[-i - 1]:
			return False
	return True
print('TAK' if check(input()) else 'NIE')


s = list(input())
if len(s) % 2 == 0:
	s1 = s[0:len(s) // 2]
	s2 = s[len(s) // 2:len(s)]
else:
	s1 = s[0:len(s) // 2 + 1]
	s2 = s[len(s) // 2:len(s)]
s2.reverse()
d = dict()
d['A'] = 'A'
d['b'] = 'd'
d['d'] = 'b'
d['H'] = 'H'
d['I'] = 'I'
d['M'] = 'M'
d['O'] = 'O'
d['o'] = 'o'
d['T'] = 'T'
d['U'] = 'U'
d['V'] = 'V'
d['v'] = 'v'
d['W'] = 'W'
d['w'] = 'w'
d['X'] = 'X'
d['x'] = 'x'
d['Y'] = 'Y'
d['p'] = 'q'
d['q'] = 'p'
f = True
for i in range(len(s1)):
	if not (s1[i] in d and d[s1[i]] == s2[i]):
		f = False
		break
if f:
	print('TAK')
else:
	print('NIE')


s = input()
syms = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y', 'p': 'q', 'q': 'p'}
if len(s) % 2 == 1 and s[len(s) // 2] in syms and (s[len(s) // 2] not in ['b', 'd', 'p', 'q']) or len(s) % 2 == 0:
	yes = True
	for i in range(len(s) // 2):
		if s[i] in syms and syms[s[i]] == s[-i - 1]:
			yes &= True
		else:
			yes = False
	print('TAK' if yes else 'NIE')
else:
	print('NIE')


a = 'AHIMOoTUVvWwXxYbdpq'
b = 'AHIMOoTUVvWwXxYdbqp'
s = input()
(l, r) = (0, len(s) - 1)
f = True
while l <= r:
	if s[l] in a:
		i1 = a.index(s[l])
	else:
		i1 = -1
	if s[r] in b:
		i2 = b.index(s[r])
	else:
		i2 = -1
	if i1 == -1:
		f = False
		break
	if i1 != i2:
		f = False
		break
	l += 1
	r -= 1
if f:
	print('TAK')
else:
	print('NIE')


import sys
m = dict(A='A', b='d', d='b', H='H', I='I', M='M', O='O', o='o', p='q', q='p', T='T', U='U', V='V', v='v', W='W', w='w', X='X', x='x', Y='Y')
s = input()
ans = ''
if len(s) == 1:
	if s in m:
		print('TAK')
		sys.exit()
	else:
		print('NIE')
		sys.exit()
if len(s) % 2 != 0:
	k = s[0:len(s) // 2 + 1]
	t = s[len(s) // 2:]
	for i in range(len(k) - 1, -1, -1):
		if k[i] in m:
			ans += m[k[i]]
		else:
			break
else:
	k = s[0:len(s) // 2]
	t = s[len(s) // 2:]
	for i in range(len(k) - 1, -1, -1):
		if k[i] in m:
			ans += m[k[i]]
		else:
			break
if ans == t:
	print('TAK')
else:
	print('NIE')


import sys
from bisect import bisect_right as rb
from collections import deque
from queue import PriorityQueue
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
inv = lambda x: pow(x, mod - 2, mod)
mod = 10 ** 9 + 7
a = 'AHIMOoTUVvWwXxY'
b = ['bd', 'db', 'pq', 'qp']
s = ip()
for i in range(len(s) // 2 + 1):
	if not (s[i] in a and s[i] == s[-1 - i] or s[i] + s[-1 - i] in b):
		print('NIE')
		exit(0)
print('TAK')


string = input()
dic = {'o': 'o', 'x': 'x', 'd': 'b', 'b': 'd', 'v': 'v', 'w': 'w', 'p': 'q', 'q': 'p'}
mid = len(string) // 2 + 1
is_p = True
for i in range(1, mid):
	(f, s) = (string[i - 1], string[i * -1])
	if f == s and f in 'AHIMOTUVWXY' or (f in dic and dic[f] == s):
		continue
	else:
		is_p = False
		break
if len(string) % 2 == 1:
	if string[mid - 1] not in 'AHIMOTUVWXYoxvw':
		is_p = False
if len(string) == 1:
	if string in 'AHIMOTUVWXY' or (string in dic and dic[string] == string):
		print('TAK')
	else:
		print('NIE')
elif is_p:
	print('TAK')
else:
	print('NIE')


string = input()
D = {'A': ['A'], 'b': ['d'], 'd': ['b'], 'H': ['H'], 'I': ['I'], 'M': ['M'], 'O': ['O'], 'o': ['o'], 'p': ['q'], 'q': ['p'], 'T': ['T'], 'U': ['U'], 'V': ['V'], 'v': ['v'], 'W': ['W'], 'w': ['w'], 'X': ['X'], 'x': ['x'], 'Y': ['Y']}
flag = 0
t = 0
if len(string) % 2 == 1:
	t = len(string) // 2 + 1
else:
	t = len(string) // 2
for i in range(t):
	if string[i] in D:
		if D[string[i]][0] == string[len(string) - 1 - i]:
			continue
		else:
			flag = 1
			break
	else:
		flag = 1
		break
if flag == 1:
	print('NIE')
else:
	print('TAK')


inv = {'d': 'b', 'b': 'd', 'A': 'A', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'x': 'x', 'X': 'X', 'Y': 'Y', 'w': 'w', 'W': 'W', 'v': 'v', 'V': 'V', 'U': 'U', 'T': 'T', 'M': 'M', 'I': 'I', 'H': 'H'}

def is_sym(s):
	l = len(s)
	for c in range(l // 2 + 1):
		if s[c] in inv:
			if inv[s[c]] != s[l - c - 1]:
				return 0
		else:
			return 0
	return 1
s = input()
if is_sym(s):
	print('TAK')
else:
	print('NIE')


s = input()
d = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}
is_sp = True
length = len(s)
left_i = 0
right_i = length - 1
while left_i <= right_i:
	left = s[left_i]
	right = s[right_i]
	if left not in d or d[left] != right:
		is_sp = False
		break
	left_i += 1
	right_i -= 1
if is_sp:
	print('TAK')
else:
	print('NIE')


def check1(a):
	if a == 'A' or a == 'H' or a == 'I' or (a == 'M') or (a == 'O') or (a == 'o') or (a == 'T') or (a == 'U') or (a == 'V') or (a == 'v') or (a == 'W') or (a == 'w') or (a == 'X') or (a == 'x') or (a == 'Y'):
		return True
	else:
		return False

def check(a, b):
	if a == b:
		return check1(a)
	else:
		if a == 'b' and b == 'd' or (a == 'd' and b == 'b'):
			return True
		if a == 'p' and b == 'q' or (a == 'q' and b == 'p'):
			return True
		return False
s = input()
n = len(s)
for i in range(int(n / 2)):
	a = s[i]
	b = s[n - 1 - i]
	if check(a, b) == False:
		print('NIE')
		exit(0)
if n % 2 != 0:
	a = s[int(n / 2)]
	if check1(a) == False:
		print('NIE')
		exit(0)
print('TAK')


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
d = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}
s = input()
ls = len(s)
if ls & 1:
	for i in range(len(s) // 2):
		if s[i] not in d:
			print('NIE')
			exit()
		elif d[s[i]] != s[-i - 1]:
			print('NIE')
			exit()
	else:
		if s[ls // 2] not in d or s[ls // 2] != d[s[ls // 2]]:
			print('NIE')
			exit()
	print('TAK')
else:
	for i in range(len(s) // 2):
		if s[i] not in d:
			print('NIE')
			exit()
		elif d[s[i]] != s[-i - 1]:
			print('NIE')
			exit()
	print('TAK')


S = input()
c = 0
for i in range(len(S) // 2):
	if S[i] == 'A' and S[len(S) - 1 - i] == 'A' or (S[i] == 'b' and S[len(S) - i - 1] == 'd') or (S[i] == 'H' and S[len(S) - i - 1] == 'H') or (S[i] == 'I' and S[len(S) - i - 1] == 'I') or (S[i] == 'd' and S[len(S) - i - 1] == 'b') or (S[i] == 'M' and S[len(S) - i - 1] == 'M') or (S[i] == 'O' and S[len(S) - i - 1] == 'O') or (S[i] == 'o' and S[len(S) - i - 1] == 'o') or (S[i] == 'T' and S[len(S) - i - 1] == 'T') or (S[i] == 'U' and S[len(S) - i - 1] == 'U') or (S[i] == 'V' and S[len(S) - i - 1] == 'V') or (S[i] == 'v' and S[len(S) - i - 1] == 'v') or (S[i] == 'W' and S[len(S) - i - 1] == 'W') or (S[i] == 'w' and S[len(S) - i - 1] == 'w') or (S[i] == 'X' and S[len(S) - i - 1] == 'X') or (S[i] == 'x' and S[len(S) - i - 1] == 'x') or (S[i] == 'Y' and S[len(S) - i - 1] == 'Y') or (S[i] == 'p' and S[len(S) - i - 1] == 'q') or (S[i] == 'q' and S[len(S) - i - 1] == 'p'):
		k = 1
	else:
		c = 1
		break
if len(S) % 2 != 0:
	if S[len(S) // 2] == 'A' or S[len(S) // 2] == 'X' or S[len(S) // 2] == 'o' or (S[len(S) // 2] == 'O') or (S[len(S) // 2] == 'x') or (S[len(S) // 2] == 'Y') or (S[len(S) // 2] == 'I') or (S[len(S) // 2] == 'M') or (S[len(S) // 2] == 'H') or (S[len(S) // 2] == 'T') or (S[len(S) // 2] == 'U') or (S[len(S) // 2] == 'V') or (S[len(S) // 2] == 'v') or (S[len(S) // 2] == 'W') or (S[len(S) // 2] == 'w'):
		if c == 0:
			print('TAK')
		else:
			print('NIE')
	else:
		print('NIE')
elif c == 1:
	print('NIE')
else:
	print('TAK')


def main():
	check = list('AbdHIMOopqTUVvWwXxY')
	qsn = list(input())
	test = [x for x in qsn if x in check]
	if test != qsn:
		print('NIE')
		return
	dict = {'Y': 'Y', 'v': 'v', 'V': 'V', 'W': 'W', 'H': 'H', 'O': 'O', 'A': 'A', 'w': 'w', 'b': 'd', 'x': 'x', 'q': 'p', 'p': 'q', 'o': 'o', 'M': 'M', 'T': 'T', 'd': 'b', 'I': 'I', 'X': 'X', 'U': 'U'}
	length = len(qsn)
	temp1 = qsn[:int(length / 2)]
	temp2 = qsn[:-(int(length / 2) + 1):-1]
	for i in range(int(length / 2)):
		if dict[temp1[i]] == temp2[i]:
			flag = 1
		else:
			print('NIE')
			return
	if length % 2 != 0 and qsn[int(length / 2)] not in list('AHIMOoTUVWwXxY'):
		print('NIE')
		return
	print('TAK')
	return
main()


from sys import stdin
mot = stdin.readline()
longueur = len(mot) - 1
milieu = longueur // 2
couples = [('A', 'A'), ('H', 'H'), ('I', 'I'), ('M', 'M'), ('O', 'O'), ('o', 'o'), ('T', 'T'), ('U', 'U'), ('V', 'V'), ('v', 'v'), ('W', 'W'), ('w', 'w'), ('X', 'X'), ('x', 'x'), ('Y', 'Y'), ('b', 'd'), ('d', 'b'), ('p', 'q'), ('q', 'p')]
inf = milieu
sup = milieu
if longueur % 2 == 0:
	inf -= 1
while inf >= 0 and sup < longueur and ((mot[inf], mot[sup]) in couples):
	inf -= 1
	sup += 1
if sup >= longueur:
	print('TAK')
else:
	print('NIE')