Mr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly one lowercase English letter into s to make it a palindrome. A palindrome is a string that reads the same forward and backward. For example, "noon", "testset" and "a" are all palindromes, while "test" and "kitayuta" are not.

You can choose any lowercase English letter, and insert it to any position of s, possibly to the beginning or the end of s. You have to insert a letter even if the given string is already a palindrome.

If it is possible to insert one lowercase English letter into s so that the resulting string will be a palindrome, print the string after the insertion. Otherwise, print "NA" (without quotes, case-sensitive). In case there is more than one palindrome that can be obtained, you are allowed to print any of them.


-----Input-----

The only line of the input contains a string s (1 ≤ |s| ≤ 10). Each character in s is a lowercase English letter.


-----Output-----

If it is possible to turn s into a palindrome by inserting one lowercase English letter, print the resulting string in a single line. Otherwise, print "NA" (without quotes, case-sensitive). In case there is more than one solution, any of them will be accepted. 


-----Examples-----
Input
revive

Output
reviver

Input
ee

Output
eye
Input
kitayuta

Output
NA



-----Note-----

For the first sample, insert 'r' to the end of "revive" to obtain a palindrome "reviver".

For the second sample, there is more than one solution. For example, "eve" will also be accepted.

For the third sample, it is not possible to turn "kitayuta" into a palindrome by just inserting one letter.

Difficulty: EASY

Solutions:
import sys
s = input().strip()

def isPalin(n):
	if n[::-1] == n:
		return True
	return False
for i in range(len(s) + 1):
	for j in 'abcdefghijklmnopqrstuvwxyz':
		if isPalin(s[:i] + j + s[i:]):
			print(s[:i] + j + s[i:])
			sys.exit(0)
print('NA')


def isPalindrome(s):
	return s[:] == s[::-1]
st = input()
i = 0
for i in range(int(len(st) / 2)):
	if st[i] != st[len(st) - i - 1]:
		break
size = len(st)
k = st[:i] + f'{st[size - i - 1]}' + st[i:]
s1 = st[:size - i] + f'{st[i]}' + st[len(st) - i:]
s2 = st[:int(size / 2) + 1] + f'{st[int(size / 2)]}' + st[int(size / 2) + 1:]
if isPalindrome(st):
	print(s2)
elif isPalindrome(k):
	print(k)
elif isPalindrome(s1):
	print(s1)
else:
	print('NA')


a = input()

def isPalindrome(word):
	if len(word) % 2 == 0:
		mid = int(len(word) / 2)
		return word[:mid] == word[mid:][::-1]
	else:
		mid = int(len(word) / 2)
		return word[:mid] == word[mid + 1:][::-1]
ok = 0
for k in range(len(a) + 1):
	for i in range(26):
		word = a[:k] + chr(ord('a') + i) + a[k:]
		if isPalindrome(word):
			ok = 1
			print(word)
			break
	if ok:
		break
if not ok:
	print('NA')


s = input()
for i in range(len(s) + 1):
	for j in range(26):
		z = s[:i] + chr(ord('a') + j) + s[i:]
		if z == z[::-1]:
			print(z)
			exit(0)
print('NA')


def ispalindrome(t, k):
	global i
	for i in range(k // 2):
		if t[i] != t[-1 - i]:
			return False
	return True
s = list(input())
l = len(s)
x = l // 2
if ispalindrome(s, l):
	s.insert(x, s[x])
	print(''.join(s))
else:
	first = s.copy()
	second = s.copy()
	first.insert(i, s[-1 - i])
	second.insert(-1 - i, s[i])
	(second[-1 - i], second[-2 - i]) = (second[-2 - i], second[-1 - i])
	if ispalindrome(first, l + 1):
		print(''.join(first))
	elif ispalindrome(second, l + 1):
		print(''.join(second))
	else:
		print('NA')


s = input()
s1 = s[::-1]
p = False

def try1(a):
	q = s[:a] + s1[a] + s[a:]
	q1 = q[::-1]
	for i in range(a + 1, len(q) // 2):
		if q[i] != q1[i]:
			return False
	return True

def try2(a):
	q = s[:len(s) - a] + s[a] + s[len(s) - a:]
	q1 = q[::-1]
	for i in range(a + 1, len(q) // 2):
		if q[i] != q1[i]:
			return False
	return True
for i in range(len(s) // 2):
	if s[i] != s1[i]:
		if try1(i):
			q = s[:i] + s1[i] + s[i:]
			print(q)
			exit(0)
		elif try2(i):
			q = s[:len(s) - i] + s[i] + s[len(s) - i:]
			print(q)
			exit(0)
		else:
			p = True
			break
if p:
	print('NA')
else:
	d = s[:len(s) // 2] + s[len(s) // 2] + s[len(s) // 2:]
	print(d)


palindrom = lambda s: s == s[::-1]
printans = lambda l: print(''.join(l))
s = list(input())
for i in range(len(s) + 1):
	for letter in 'abcdefghijklmnopqrstvwuxyz':
		tmp = s[:]
		tmp.insert(i, letter)
		if palindrom(tmp):
			printans(tmp)
			exit()
print('NA')


from string import ascii_lowercase

def check(s):
	return s == s[::-1]
s = input()
for i in range(len(s) + 1):
	for c in ascii_lowercase:
		if check(s[:i] + c + s[i:]):
			print(s[:i] + c + s[i:])
			exit()
print('NA')


s = input()
n = len(s)
for i in range(n + 1):
	new_s = s[:i] + s[-i - (i <= n // 2)] + s[i:]
	if new_s == new_s[::-1]:
		print(new_s)
		break
else:
	print('NA')


s = input()
lens = len(s)
flag = 0
for i in range(0, lens + 1):
	for j in range(ord('a'), ord('z') + 1):
		s1 = s
		s1 = s[:i] + chr(j) + s[i:]
		s2 = s1[::-1]
		if s1 == s2:
			print(s1)
			flag = 1
			break
	if flag == 1:
		break
if flag == 0:
	print('NA')


def ptest(l):
	m = l[:]
	m.reverse()
	if m == l:
		return True
	return False
a = input()
a = list(a)
lett = set(a)
done = False
for x in range(len(a) + 1):
	b = a[:]
	for t in lett:
		c = b[:x] + [t] + b[x:]
		c.reverse()
		if ptest(c):
			done = True
			print(''.join(c))
			break
	if done:
		break
if not done:
	print('NA')


s = list(input())
se = set(s)
ans = False
for i in range(11):
	for j in se:
		st = s.copy()
		st.insert(i, j)
		if st == st[::-1]:
			ans = True
			break
	if ans:
		break
if ans:
	print(''.join(st))
else:
	print('NA')


s = input()
n = len(s)
for i in range(n + 1):
	for j in range(26):
		k = s[0:i] + chr(j + 97) + s[i:n]
		if k == k[::-1]:
			print(k)
			exit(0)
print('NA')


s = str(input())

def ispalindrome(s):
	if s == s[::-1]:
		return True
	return False
for i in range(len(s) + 1):
	if i < len(s) / 2:
		t = s[:i] + s[len(s) - i - 1] + s[i:]
	else:
		t = s[:i] + s[len(s) - i] + s[i:]
	if ispalindrome(t):
		print(t)
		quit()
print('NA')


s = input()
for i in range(len(s) + 1):
	for j in range(97, 123):
		q = s[:i] + chr(j) + s[i:]
		if q == q[::-1]:
			print(q)
			exit()
print('NA')


from string import ascii_lowercase
s = input()
n = len(s)
for i in range(n + 1):
	for char in ascii_lowercase:
		new_s = s[:i] + char + s[i:]
		if new_s == new_s[::-1]:
			print(new_s)
			exit()
print('NA')


from math import *
from sys import stdin, stdout
import itertools
import os
import sys
import threading
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import *
from fractions import Fraction
mod = int(pow(10, 9) + 7)

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

def si():
	return str(input())

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

def li():
	return list(mi())

def fii():
	return int(stdin.readline())

def fsi():
	return str(stdin.readline())

def fmi():
	return map(int, stdin.readline().split())

def fli():
	return list(fmi())
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d:
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d:
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = defaultdict(list)
	for i in range(n):
		(x, y) = mi()
		d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			s.add(i)
			n = n // i
	if n > 2:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)

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

def dijkstra(edges, f, t):
	g = defaultdict(list)
	for (l, r, c) in edges:
		g[l].append((c, r))
	(q, seen, mins) = ([(0, f, ())], set(), {f: 0})
	while q:
		(cost, v1, path) = heappop(q)
		if v1 not in seen:
			seen.add(v1)
			path = (v1, path)
			if v1 == t:
				return (cost, path)
			for (c, v2) in g.get(v1, ()):
				if v2 in seen:
					continue
				prev = mins.get(v2, None)
				next = cost + c
				if prev is None or next < prev:
					mins[v2] = next
					heappush(q, (next, v2, path))
	return float('inf')

def binsearch(a, l, r, x):
	while l <= r:
		mid = l + (r - 1) // 2
		print(mid)
		if a[mid]:
			return mid
		elif a[mid] > x:
			l = mid - 1
		else:
			r = mid + 1
	return -1
f = 0
s = list(si())
x = tuple(s)
out = []
for i in range(len(s) + 1):
	for j in range(97, 97 + 26):
		s = list(x)
		s.insert(i, chr(j))
		out.append(''.join(s))
for i in out:
	if i == i[::-1]:
		print(i)
		f = 1
		break
if f == 0:
	print('NA')


a = input()
dead = False
semidead = False
fr = 0
ind = None
d = 0
for i in range(len(a) // 2):
	if a[i - min(fr, 0)] != a[-i - 1 - max(fr, 0)]:
		if d == 0:
			if a[i] == a[-i - 2]:
				fr = 1
				ind = i
				d += 1
			elif a[i + 1] == a[-i - 1]:
				fr = -1
				ind = len(a) - i - 1
				d += 1
			else:
				dead = True
				print('NA')
				break
		else:
			semidead = True
			break
if semidead:
	d = 0
	fr = 0
	for i in range(len(a) // 2):
		if a[i - min(fr, 0)] != a[-i - 1 - max(fr, 0)]:
			if d == 0:
				if a[i] == a[-i - 2]:
					if fr != -1:
						if a[i + 1] == a[-i - 1]:
							fr = -1
							ind = len(a) - i - 1
							d += 1
						else:
							dead = True
							print('NA')
							break
					else:
						ind = i
						d += 1
				elif a[i + 1] == a[-i - 1]:
					if fr != 1:
						dead = True
						print('NA')
						break
					ind = len(a) - i - 1
					d += 1
				else:
					dead = True
					print('NA')
					break
			else:
				dead = True
				print('NA')
				break
if not dead:
	if d == 0:
		print(a[0:len(a) // 2], a[len(a) // 2], a[len(a) // 2:], sep='')
	elif fr == 1:
		print(a[0:ind], a[-1 - ind], a[ind:], sep='')
	else:
		print(a[0:ind + 1], a[len(a) - 1 - ind], a[ind + 1:], sep='')


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 1000000007
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
s = list(input())
n = len(s)
for i in range(n + 1):
	a = s[:]
	a.insert(i, 'A')
	ok = True
	l = 0
	r = n
	while l < r:
		if a[l] == 'A':
			a[l] = a[r]
			l += 1
			r -= 1
		elif a[r] == 'A':
			a[r] = a[l]
			l += 1
			r -= 1
		elif a[l] == a[r]:
			l += 1
			r -= 1
		else:
			ok = False
			break
	if ok:
		print(''.join(a).lower())
		exit()
print('NA')


z = input()
arr = []
for i in z:
	arr.append(i)
i = 0
count = 0
while i < len(z) // 2 and count < 2:
	if arr[i] == arr[-i - 1]:
		i += 1
		continue
	else:
		count += 1
		if arr[i] == arr[-2 - i] and arr[-i - 1] == arr[i + 1]:
			arr.insert(i, arr[-i - 1])
			for k in range(len(arr) // 2):
				if arr[k] == arr[-k - 1]:
					continue
				else:
					del arr[i]
					if -1 - i == -1:
						arr.append(arr[i])
					else:
						arr.insert(-i, arr[i])
		elif arr[i] == arr[-2 - i]:
			arr.insert(i, arr[-i - 1])
		elif arr[-i - 1] == arr[i + 1]:
			if -1 - i == -1:
				arr.append(arr[i])
			else:
				arr.insert(-i, arr[i])
		else:
			count = 10
			break
		i += 1
if count == 0:
	count += 1
	arr.insert(len(arr) // 2, arr[len(arr) // 2])
for i in range(len(arr) // 2):
	if arr[i] == arr[-i - 1]:
		continue
	else:
		count = 10
if len(arr) == 1:
	arr.append(arr[0])
if count < 2:
	for i in arr:
		print(i, end='')
	print()
else:
	print('NA')


s = input()

def chk(s):
	for i in range(len(s)):
		if s[i] != s[len(s) - i - 1]:
			return False
	return True
for i in range(len(s) + 1):
	for j in range(26):
		ns = s[:i] + chr(ord('a') + j) + s[i:]
		if chk(ns):
			print(ns)
			exit(0)
print('NA')


s = input()
n = len(s)
for _ in range(n + 1):
	s1 = s[:_] + '!' + s[_:]
	s2 = s1[::-1]
	a = '?'
	for i in range(n + 1):
		if s1[i] == '!' and s2[i] != '!':
			if a == '?':
				a = s2[i]
			elif s2[i] == a:
				print(s[:_] + a + s[_:])
				exit(0)
			else:
				print('NA')
				exit(0)
		elif s1[i] != '!' and s2[i] == '!':
			if a == '?':
				a = s1[i]
			elif s1[i] == a:
				print(s[:_] + a + s[_:])
				exit(0)
			else:
				print('NA')
				exit(0)
		elif s1[i] == s2[i] == '!':
			print(s[:_] + 'a' + s[_:])
			exit(0)
		elif s1[i] != s2[i]:
			break
print('NA')


import sys

def is_p(s):
	return s == s[::-1]
s = input()
for i in range(len(s) + 1):
	for c in 'abcdefghijklmnopqrstuvwxyz':
		t = s[:i] + c + s[i:]
		print(t, file=sys.stderr)
		if is_p(s[:i] + c + s[i:]):
			print(s[:i] + c + s[i:])
			exit(0)
print('NA')


letters = list('abcdefghijklmnopqrstuvwxyz')

def insertLetter(letter, word, pos):
	return word[:pos] + letter + word[pos:]

def isPalidrome(word):
	length = len(word)
	if length % 2 == 0:
		firstHalf = word[:int(length / 2)]
		secondHalf = word[length:int(length / 2) - 1:-1]
		if firstHalf == secondHalf:
			return True
		else:
			return False
	else:
		firstHalf = word[:int(length / 2)]
		secondHalf = word[length:int(length / 2):-1]
		if firstHalf == secondHalf:
			return True
		else:
			return False

def findPalidrome(word):
	for i in range(len(word) + 1):
		for letter in letters:
			newWord = insertLetter(letter, word, i)
			if isPalidrome(newWord):
				return newWord
	return 'NA'
word = input()
print(findPalidrome(word))


def pal(a):
	ctr = 0
	while ctr < len(a) / 2:
		if a[ctr] != a[len(a) - ctr - 1]:
			return False
		ctr += 1
	return True
a = input()
alp = []
p = 'NA'
if not len(a) > 10 or len(a) < 1:
	if a.islower():
		for char in a:
			if not char in alp:
				alp.append(char)
		length = len(a)
		for char in alp:
			ctr = 0
			while ctr <= length:
				new = a[:ctr] + char + a[ctr:]
				if pal(new):
					p = new
				ctr += 1
		print(p)


def palindrom(s):
	n = len(s)
	for num in range(n):
		if s[num] != s[n - num - 1]:
			return 0
	return 1
s = input()
n = len(s)
words = 'abcdefghjklmnpoqrstvwxyziuy'
yes = 0
s1 = ''
for i in range(n + 1):
	for j in words:
		if palindrom(s[:i] + j + s[i:]) == 1:
			s1 = s[:i] + j + s[i:]
			yes = 1
			break
	if yes == 1:
		break
if s1 == '':
	print('NA')
else:
	print(s1)


s = [x for x in input()]
for i in range(len(s) + 1):
	for j in range(ord('a'), ord('z') + 1):
		t = s[:]
		t.insert(i, chr(j))
		(l, k) = (0, len(t) - 1)
		while l < k:
			if t[l] == t[k]:
				l += 1
				k -= 1
			else:
				break
		else:
			print(''.join(t))
			exit(0)
print('NA')


s = input()
f = 0
alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for i in range(len(s) + 1):
	for j in alpha:
		t = s[:i] + j + s[i:]
		if t == t[::-1]:
			print(t)
			exit()
print('NA')


def f(s):
	at = -1
	for (i, v) in enumerate(s):
		if v == '@':
			at = i
			continue
		if v != s[-i - 1] and s[-i - 1] != '@':
			return False
	s[at] = s[-at - 1]
	return ''.join(s)
s = list(input())
for i in range(len(s) + 1):
	s.insert(i, '@')
	a = f(s)
	if a:
		print(a)
		break
	del s[i]
else:
	print('NA')


from string import ascii_lowercase
word = str(input())
found = False

def get_palindrome(word, len):
	global found
	for letter in ascii_lowercase:
		new_word = word[:x] + letter + word[x:]
		if new_word[::-1] == new_word:
			print(new_word)
			found = True
			return
for x in range(len(word) + 1):
	if not found:
		get_palindrome(word, x)
if not found:
	print('NA')


def main():
	s = input()
	for i in range(len(s) + 1):
		for sym in range(ord('a'), ord('z') + 1):
			sym = chr(sym)
			st = s[:i] + sym + s[i:]
			if st == st[::-1]:
				print(st)
				return
	print('NA')
main()


a = []
for i in range(97, 123):
	a.append(chr(i))
s = input()
n = len(s)
flag = False
for i in range(n + 1):
	if flag == False:
		for j in a:
			x = s[0:i] + j + s[i:n]
			if x == x[::-1]:
				y = x
				flag = True
				break
if flag == False:
	print('NA')
else:
	print(y)


__author__ = 'artyom'

def main():
	s = list(read(0))
	n = len(s)
	m = n // 2
	for i in range(n + 1):
		p = s[:i] + [s[n - i - (i <= m)]] + s[i:n]
		if p == p[::-1]:
			return p
	return 'NA'

def read(mode=2):
	inputs = input().strip()
	if mode == 0:
		return inputs
	if mode == 1:
		return inputs.split()
	if mode == 2:
		return int(inputs)
	if mode == 3:
		return list(map(int, inputs.split()))

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, list):
		s = ''.join(map(str, s))
	s = str(s)
	print(s, end='')
write(main())


import string
s = input()
done = False
for i in range(len(s) + 1):
	for a in string.ascii_lowercase:
		ns = s[:i] + a + s[i:]
		if ns == ns[::-1]:
			print(ns)
			done = True
			break
	if done:
		break
if not done:
	print('NA')


TN = 1

def solution():
	s = list(input())
	n = len(s)
	ans = []
	for i in range(n):
		ans.append(s[:i] + [s[-i - 1]] + s[i:])
		ans.append(s[:i + 1] + [s[-i - 1]] + s[i + 1:])
	for i in range(len(ans)):
		for j in range(len(ans[i]) // 2 + 1):
			if ans[i][j] != ans[i][-j - 1]:
				break
		else:
			print(''.join(ans[i]))
			break
	else:
		print('NA')
while TN != 0:
	solution()
	TN -= 1


import string

def jud(l=[]):
	n = len(l)
	for i in range(n):
		if l[i] != l[n - i - 1]:
			return False
	return True
s = input('')
n = len(s)
arr = list(s)
flag = False
for i in range(n + 1):
	if flag:
		break
	for c in string.ascii_lowercase:
		if flag:
			break
		arr.insert(i, c)
		if jud(arr):
			print(''.join(arr))
			flag = True
		arr.pop(i)
if not flag:
	print('NA')


s = input()
for i in range(len(s) + 1):
	for j in range(97, 123):
		a = chr(j)
		t = s[:i] + a + s[i:]
		if t == t[::-1]:
			print(t)
			exit()
print('NA')


def palindrome(s):
	if list(s) == list(reversed(list(s))):
		return 1
	return 0
s = input()
done = 0
for i in range(0, len(s) + 1):
	for j in range(97, 123):
		l = s[:i] + chr(j) + s[i:]
		if palindrome(l) == 1 and done == 0:
			print(l)
			done = 1
if done == 0:
	print('NA')


import string

def main():
	s = input()
	for i in range(len(s) + 1):
		for a in string.ascii_lowercase:
			ns = s[:i] + a + s[i:]
			if ns == ns[::-1]:
				print(ns)
				return
	print('NA')
main()


s = input()
n = len(s)

def symi(i, k):
	if min(k, n - k - 1) < min(i, n - i - 1):
		return n - k - 1
	elif min(k, n - k - 1) > min(i, n - i - 1) and i > n // 2:
		return n - k
	elif min(k, n - k - 1) > min(i, n - i - 1):
		return n - k - 2
	else:
		return k

def ispal(s, i):
	b = True
	for k in range(n):
		if s[symi(i, k)] != s[k]:
			b = False
	return b

def res(s):
	for i in range(n):
		if ispal(s, i):
			if i > n // 2:
				sp = s[:i + 1] + s[n - i - 1] + s[i + 1:]
			else:
				sp = s[:i] + s[n - i - 1] + s[i:]
			return sp
	return 'NA'
print(res(s))


abc = 'abcdefghijklmnopqrstuvwxyz'

def is_palindrome(s):
	if s == s[::-1]:
		return True
	else:
		return False
s = input()
for i in range(len(s) + 1):
	for t in abc:
		s2 = s[:i] + t + s[i:]
		if is_palindrome(s2):
			print(s2)
			exit(0)
print('NA')


s = input()
if s == s[::-1]:
	print(s[:len(s) // 2] + s[len(s) // 2] + s[len(s) // 2:])
else:
	for i in range(len(s) // 2):
		if s[i] != s[len(s) - 1 - i]:
			first = s[:i] + s[len(s) - 1 - i] + s[i:]
			second = s[:len(s) - i] + s[i] + s[len(s) - i:]
			if first == first[::-1]:
				print(first)
			elif second == second[::-1]:
				print(second)
			else:
				print('NA')
			break


st = list(input())
for i in range(len(st) + 1):
	for j in range(26):
		sti = st.copy()
		sti.insert(i, chr(97 + j))
		if sti == sti[::-1]:
			print(''.join(sti))
			exit()
print('NA')


s = input()
for i in range(len(s) + 1):
	for j in 'abcdefghijklmnopqrstuvwxyz':
		t = s[:i] + j + s[i:]
		if t == t[::-1]:
			print(t)
			exit()
print('NA')


def ispal(s):
	i = 0
	j = len(s) - 1
	while i < j:
		if s[i] != s[j]:
			return False
		i += 1
		j -= 1
	return True
alpha = 'abcdefghijklmnopqrstuvwxyz'
found = 0
s = input()
for i in range(0, len(s) + 1):
	for j in range(len(alpha)):
		temp = s[:i] + alpha[j] + s[i:]
		if ispal(temp):
			found = 1
			print(temp)
			break
	if found:
		break
if not found:
	print('NA')


def func(s):
	for i in range(len(s) + 1):
		for j in range(97, 123):
			q = s[:i] + chr(j) + s[i:]
			rev = q[::-1]
			if q == rev:
				return q
	return 'NA'
s = input()
print(func(s))


def check(word):
	newWord = list(word)
	l = len(word) - 1
	i = 0
	while l != -1:
		newWord[i] = word[l]
		i += 1
		l -= 1
	if word == newWord:
		return True
	return False

def Main():
	s = input()
	leng = len(s)
	symbol = leng - 1
	s = list(s)
	newS = s.copy()
	insertPos = 0
	for char in s:
		if symbol == insertPos:
			newS.insert(insertPos, 'a')
			if check(newS.copy()):
				print(''.join(newS))
				return
		else:
			newS.insert(insertPos, s[symbol])
			if check(newS.copy()):
				print(''.join(newS))
				return
		newS = s.copy()
		symbol -= 1
		insertPos += 1
	symbol = 0
	insertPos = leng
	newS = s.copy()
	for char in s:
		if symbol == insertPos:
			newS.insert(insertPos, 'a')
			if check(newS.copy()):
				print(''.join(newS))
				return
		else:
			newS.insert(insertPos, s[symbol])
			if check(newS.copy()):
				print(''.join(newS))
				return
		newS = s.copy()
		symbol += 1
		insertPos -= 1
	newS = s.copy()
	newS.append(s[0])
	if check(newS):
		print(''.join(newS))
		return
	print('NA')
Main()


alph = list('abcdefghijklmnopqrstuvwxyz')

def pal(s):
	l = len(s)
	f = 1
	lim = l / 2
	l -= 1
	for i in range(int(lim)):
		if s[i] != s[l - i]:
			f = 0
	return f
s = input()
l = len(s) + 1
f = 0
for i in range(l):
	for j in alph:
		st = list(s)
		st.insert(i, j)
		st = ''.join(st)
		if pal(st) == 1:
			f = 1
			break
	if f == 1:
		break
if f == 1:
	print(st)
else:
	print('NA')