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: interview

Starter code:

Solutions:
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')
    


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")

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')


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')

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")

s = input()

p = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'

for c in s:
    if c in p:
        print('NIE')
        return

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')


midsym = 'AHIMOoTUVvWwXxY'
sym = 'pqbd'

s = input()

if len(s) % 2 == 1:
	t = len(s) // 2
	if s[t] not in midsym:
		print('NIE')
		return
	s = s[:t] + s[t+1:]

#print(s)
	
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')
		return
	if f[k] in midsym:
		if l[k] != f[k]:
			print('NIE')
			return
	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')
		return
print('TAK')

# You lost the game.
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")
    else:
        if s[n//2 + n%2:] == r:
            print("TAK")
        else:
            print("NIE")


s = input()

selfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???

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
    else:
        if 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")

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()
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")
        return
if len(s) % 2 == 1:
    if s[len(s) // 2] in good:
        print("TAK")
    else:
        print("NIE")
else:
    print("TAK")

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 = 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
    else:
        if 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")





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")



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()

f = True

if len(s) % 2 == 0:
    l = s[:len(s) // 2]
    r = s[len(s) // 2:]
else:
    l = s[:len(s) // 2]
    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:
        f = False
    r = s[len(s) // 2 + 1:]

r = list(r)
for i in range(len(r)):
    if r[i] not in d:
        f = False
    else:
        r[i] = d[r[i]]

if r[::-1] == list(l) and f:
    print("TAK")
else:
    print("NIE")


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))


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()

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')


__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")
        return
    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")
            return
    elif string[i] != string[-i-1]:
        sys.stdout.write("NIE")
        return
sys.stdout.write("TAK")

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")


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')


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")
        return
print("TAK")

    


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:
    #ans = False
    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")