from sys import stdin, stdout
from itertools import permutations as perms

def is_palindrome(line):
	for i in range(0, len(line)):
		if line[i]!=line[len(line)-i-1]:
			return False
	return True

def main():
	line=stdin.readline().rstrip()
	for i in range(0, len(line)+1):
		for each in map(chr, range(ord('a'), ord('z')+1)):
			my_str=line[0:i]+each+line[i:]
			if is_palindrome(my_str):
				print(my_str)
				return
	print('NA')

if __name__=='__main__':
	main()

# -*- coding: utf-8 -*-

import itertools

if __name__ == '__main__':
    s = raw_input()

    result = 'NA'
    alphabet = 'abcdefghijklmnopqrstuvyxwz'
    for i, a in itertools.product(range(len(s)+1), alphabet):
        candidate = s[:i] + a + s[i:]
        if candidate == candidate[::-1]:
            result = candidate
            break
    print(str(result))

def isPalindrome(s):
	n = len(s)
	for i in xrange(n / 2):
		if s[i] != s[n - 1 - i]: return False
	return True

def main():
	s = map(str, raw_input())
	for i in xrange(len(s) + 1):
		for j in xrange(26):
			sNew = s[: i] + [chr(ord('a') + j)] + s[i:]
			if isPalindrome(sNew):
				print "".join(sNew)
				return
	print "NA"

main()

s=list(raw_input())

for i in range(26):
    l=chr(ord('a')+i)
    for j in range(len(s)+1):
        s1=s[:j]+[l]+s[j:]
        #print s1
        if s1==s1[::-1]:
            print ''.join(s1)
            exit(0)
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")

from math import ceil, floor

s = input()
l = len(s)
h1, h2 = ceil(l / 2), floor(l / 2)

if s[:h1] == ''.join(list(reversed(s[h2:]))):
    print(s[:h1] + s[h2] + s[h1:])
else:
    s1, s2 = list(s), list(s)
    for i in range(h1):
        if s[i] != s[-(i + 1)]:
            s1.insert(l - i, s[i])
            s2.insert(i, s[-(i + 1)])
            break

    l = len(s1)
    h1, h2 = ceil(l / 2), floor(l / 2)
    if s1[:h1] == list(reversed(s1[h2:])):
        print(''.join(s1))
    elif s2[:h1] == list(reversed(s2[h2:])):
        print(''.join(s2))
    else:
        print('NA')

s=input()
n=len(s)
f=0
for i in range(n+1):
    for j in range(26):
        l=s[:i]+chr(97+j)+s[i:]
        if(l==l[::-1]):
            f=1
            print(l)
            break
    if(f==1):
        break
if f==0:
    print("NA")

"""
Author    : co_devil Chirag Garg
Institute : JIIT
"""
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 math import ceil, floor, log, sqrt, factorial, pow, pi, gcd
# from bisect import bisect_left,bisect_right
# from decimal import *,threading
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")

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

a = input()

def isPalindrome(word):
    if(len(word) % 2 == 0):
        mid = int(len(word) / 2)
        #print(word[:mid], word[mid:][::-1])
        return (word[:mid] ==  word[mid:][::-1])
    else:
        mid = int(len(word) / 2)
        #print(word[:mid], word[(mid + 1):][::-1])
        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:]
        #print(word)
        if(isPalindrome(word)):
            ok = 1
            print(word)
            break
    if(ok):
        break
if(not ok):
    print("NA")

s = raw_input()
alpha = map(chr,range(ord('a'),ord('z')+1))
STOP = False
for i in range( 0 , len(s) + 1 ):
   if STOP:
      break
   first_half = s[ 0 : i ]
   second_half = s[ i:: ]
   for a in alpha:
      S = first_half + a + second_half
      #print first_half,a,second_half
      if S == s:
         continue
      if S==S[::-1]:
         print S
         STOP = True
         break

if STOP == False:
   print "NA"

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

s=input()

def palin(p):
   w=0
   if len(p)==1:
      return True
   else:
      for i in range(len(p)//2):
         if p[i]!=p[-1-i]:
            w=2
            break
         else:
            w=0
      if w==0:
         return True
      else:
         return False

def same(e):
   t=e[0]
   r=1
   for i in range(1,len(e)):
      if e[i]!=t:
         r=2
         break
   if r==2:
      return False
   else:
      return True

if same(s)!=True:

   if len(s)==1:
      t=s+s
      print(t)
   elif palin(s)==True:
      if len(s)%2==0:
         r=len(s)//2
         w=s[0:r]+"a"+s[r:len(s)]
         print(w)
      else:
         s=s[0:len(s)//2+1]+s[len(s)//2]+s[len(s)//2+1:]

         print(s)
   else:
      for i in range(len(s)):
         if s[i]!=s[-1-i]:
            m=s[-1-i]+s[i:(len(s)-i)]
            n=s[i:(len(s)-i)]+s[i]

            if palin(m)==True:
               d=s[0:i]+m+s[len(s)-i:]
               print(d)
               break
            elif palin(n)==True:
               d=s[0:i]+n+s[len(s)-i:]
               print(d)
               break
            else:
               print("NA")
               break

else:
   s=s+s[0]
   print(s)

from sys import stdin
import string

s = stdin.readline()[:-1]
for i in xrange(len(s) + 1):
    t1, t2 = "", ""
    for ch in string.ascii_lowercase:
        t1 = s[:i] + str(ch) + s[i:]
        t2 = t1[::-1]
        if t1 == t2:
            break
    if t1 == t2:
        print t1
        break
else:
    print "NA"

s = input()
def check(a):
	n = len(a)
	for i in range(n//2):
		if(a[i]!=a[n-i-1]):
			return False
	return True
import sys
for i in range(26):
	x = chr(ord('a')+i)
	for i in range(len(s)+1):
		if(check(s[:i]+x+s[i:])):
			print(s[:i]+x+s[i:])
			sys.exit(0)
print('NA')

s = input()
l = (len(s)+1)//2
k = 'qwertyuiopasdfghjklzxcvbnm'
ans = 'NA'
for i in range(len(s)+1):
    for j in k:
        e = ''
        b = s
        b = s[:i]+j+s[i:]
        r = [x for x in b[-l:]]
        r.reverse()
        for c in r:
            e = e + c
        if b[:l] == e:
            ans = b
print(ans)

import string
def jud(l=[]):
	n=len(l)
	#print(n)
	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')

def is_palindrome(s):
    return s == s[::-1]
s=raw_input("")
y=len(s)-1
x=0
l=list(s)
flag=0
check=0
if len(l)==2 and l[0]!=l[1]:
    l.insert(0,l[1])
    check=1
while x<=y:
    if check==1:
        break
    if l[x]!=l[y]:
        if l[y-1]==l[x]:
            if x==0:
                l.insert(0,l[y])
                s3=''.join(l)
                if is_palindrome(s3):
                    flag=1
                    break
                else:
                    l.remove(l[0])
                    l.append(l[0])
                    s4=''.join(l)
                    if is_palindrome(s4):
                        flag=1
                        break
                    flag=2
                    break
            l.insert(x,l[y])
            flag=1
        elif l[y]==l[x+1]:
            l.insert(y+1,l[x])
            s3=''.join(l)
            if is_palindrome(s3):
                flag=1
                break
            else:
                flag=2
                break
            flag=1
        else:
            flag=2

        break
    x+=1
    y-=1
if check==1:
    print ''.join(l)
elif flag==0:
    s=str(''.join(l[0:len(l)/2]))+l[len(l)/2]
    if len(l)%2==0:
        l=l[0:len(l)/2]
    else:
        l=l[0:len(l)/2+1]
    l.reverse()
    s=s+str(''.join(l))
    print s
elif flag==1:
    s1=''.join(l)
    print s1
elif flag==2:
    print "NA"

def isPalin(s):
	if s==s[::-1] :
		return True
	else :
		return False

s=raw_input()

alpha='abcdefghijklmnopqrstuvwxyz'
done=False
for i in xrange(len(s)+1) :
	for ch in alpha :
		s1=s[:i]+ch+s[i:]
	#	print "s1",s1
		if isPalin(s1) :
			print s1
			done=True
			break
	if done :
		break
if not done :
	print "NA"

s = input()
al = 'abcdefghijklmnopqrstuvwxyz'
ans = False
for i in range(26): ### it's just a o(1)
    for j in range(len(s)+1):
        tmp = s[:j]+al[i]+s[j:]

        if tmp==tmp[::-1]:
            print(tmp)
            exit()
print('NA')

from sys import stdin
def ch(s):
 t = ''+s
 t = t[::-1]
 return t==s
x = stdin.readline().strip()
l = len(x)
ans = 'NA'
y = 'abcdefghijklmnopqrstuvwxyz'
for i in xrange(l+1):
 fir = x[0:i]
 sec = x[i:l]
 for j in y:
  nn = fir + j + sec
  #print "checking for ",nn
  if ch(nn):
   ans = nn
print ans

from sys import stdin

def main():
  s = stdin.readline().rstrip()
  for i in range(len(s)+1):
    for j in range(26):
      copy = s[:]
      copy = s[0:i] + chr(j+ord('a')) + s[i:]
      if other_check(copy):
        print copy
        return
  print "NA"

def other_check(string):
  for i in range(len(string)//2):
    if not string[i]==string[-(i+1)]:
      return False
  return True

main()

def check(word,i,j):
    while i<j:
        if word[i]!=word[j]:
            return False
        i=i+1
        j=j-1
    return True
if __name__ == '__main__':
    word = raw_input()
    mid=(len(word)-1)//2
    if check(word,0,len(word)-1)==True:
        print word[:mid+1]+word[mid]+word[mid+1:]
    else:
        success=False
        i,j = 0,len(word)-1
        while word[i]==word[j]:
            i=i+1
            j=j-1
        if check(word,i,j-1)==True:
            print word[:i]+word[j]+word[i:]
        elif check(word,i+1,j)==True:
            print word[:j+1]+word[i]+word[j+1:]
        else:
            print 'NA'

import sys
def verify(s):
    n = len(s)
    for i in xrange(n / 2):
        if (s[i] != s[n - 1 - i]): return 0
    return 1

def pr(s):
    for i in xrange(len(s)):
        sys.stdout.write('%s' % s[i])
    sys.stdout.write('\n')

s = list(raw_input())
n = len(s)
if (verify(s)):
    if (n % 2 == 0):
        s.insert(n / 2, 'a')
    else:
        s.insert(n / 2 + 1, s[n / 2])
    pr(s)
else:
    s2 = s[::-1]
    for i in xrange(n):
        if (s[i] != s2[i]):
            tmp1 = s[i]
            tmp2 = s2[i]
            s.insert(i, tmp2)
            s2.insert(i, tmp1)
            break
    if (verify(s)):
        pr(s)
    elif (verify(s2)):
        pr(s2)
    else:
        print 'NA'

def palindrome(s):
    n=len(s)
    for i in range(n//2):
        if s[i]!=s[n-1-i]:
            return False
    return True
s=input()
n=len(s)
for i in range(n+1):
    for j in range(26):
        c=chr(ord('a')+j)
        tmp=''
        if i>0:
            tmp=s[0:i]
        tmp+=str(c)
        if i<=n-1:
            tmp+=s[i:]
        if palindrome(tmp):
            print(tmp)
            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")

s=input()
n=len(s)
for i in range(n+1):
    for j in range(26):
        c=chr(ord('a')+j)
        tmp=''
        if i>0:
            tmp=s[0:i]
        tmp+=str(c)
        if i<=n-1:
            tmp+=s[i:]
        if tmp==tmp[::-1]:
            print(tmp)
            exit(0)
print('NA')

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

s = raw_input("")
n = len(s)
i = 0
j = n - 1
tries = 1
s1 = s
while s1[i] == s1[j] and i < n/2:
    i += 1
    j -= 1
i1 = i
j1 = j
s1 = s[:i] + s[j] + s[i:]
j += 1
#print s1, i, j
while s1[i] == s1[j] and i < n:
    i += 1
    j -= 1
#print s1[i], s1[j], i, n
if i == n:
    print s1
else:
    s2 = s[:j1+1] + s[i1] + s[j1+1:]
    #print s2, i, j
    #i += 1
    while s2[i] == s2[j] and i < n:
        i += 1
        j -= 1
    if i == n:
        print s2
    else:
        print "NA"

s = list(input())
n = len(s)
candidates = [s + ['.']]
res = 'NA'

for i in range(n):
    candidates.append(s[:i] + ['.'] + s[i:])

for s in candidates:
    legal = True
    for i in range((n + 1) // 2):
        if s[i] == s[-i-1] or s[i] == '.' or s[-i-1] == '.':
            continue
        legal = False
    if legal:
        res = s

if res != 'NA':
    for i in range((n + 1) // 2):
        if res[i] == '.':
            res[i] = res[-i-1]
        elif res[-i-1] == '.':
            res[-i-1] = res[i]
    res = [s if s != '.' else 'a' for s in res]
    res = ''.join(res)

print(res)

def isPalindrome(s):
    ns = len(s)
    for i in range(ns/2):
        if s[i] != s[ns - 1 - i]:
            return False
    return True

def sol():
    s = str(raw_input())
    ns = len(s)
    if isPalindrome(s):
        if ns % 2 == 0:
            print s[:(ns/2)] + 'a' + s[(ns/2):]
        else:
            print s[:(ns/2 + 1)] + s[(ns/2):]
        return

    for i in range(ns):
        if s[i] != s[ns - 1 - i]:
            if isPalindrome(s[i:ns-1-i]):
                print s[:i] + s[ns - 1 - i] + s[i:]
            else:
                if isPalindrome(s[i+1:ns-i]):
                    print s[:ns - i] + s[i] + s[ns-i:]
                else:
                    print 'NA'
            return

sol()

a = raw_input().strip()
lena = len(a)
nf = True
i = 0
while nf and i < lena:
	ai = a[i]
	# print ai
	x = 0
	while nf and x < (lena+1):
		p = a[:x]
		q = ai
		r = a[x:]
		pqr = p + q + r
		s = pqr[:(lena+1)/2]
		t = pqr[(lena+2)/2:][::-1]
		# print p,q,r,'->',pqr,'->',s,t
		if s == t:
			print pqr
			exit()
		x += 1
	i += 1
	# print
print "NA"

#
# Uian Sol Gorgonio <sol.uian@gmail.com>
# Feb 7 2015
# Mr. Kitayuta's Gift
# http://codeforces.com/contest/505/problem/A
#
# brute force
#

def is_anagram(word):
    for i in xrange(len(word) / 2):
        if word[i] != word[-i-1]:
            return False
    return True

word = list(raw_input())

letters = list(set(word))
found = False
for letter in letters:
    for i in xrange(len(word) + 1):
        aux = word[::]
        aux.insert(i, letter)
        if is_anagram(aux):
            print ''.join(aux)
            found = True
            break

    if found: break

if not found:
    print 'NA'

x = input()
d = False
for c in range(97,123):
    if ( d):
        break
    for i in range(len(x) + 1):
        n = x[:i] + chr(c) + x[i:]
        if n == n[::-1]:
            print (n)

            d= True
            break

if (not d):
    print ("NA")

import string

s = raw_input()

res = 'NA'
for i in range(len(s)+1):
   for v in string.lowercase:
      ss = s[:i]+v+s[i:]
      if ss == ss[::-1]:
         res = ss

print res

s=input()
i=0
def checkpa(st):
    if st==st[::-1]:
        return 1
    else:
        return 0
while i<=len(s)-1 and s[i]==s[len(s)-1-i]:
    i+=1
if i==len(s):
    if len(s)%2==0:
        print(s[:len(s)//2]+'a'+s[len(s)//2:])
    else:
        print(s[:len(s)//2]+s[len(s)//2]*2+s[len(s)//2+1:])
elif i==0:
    s1=s[len(s)-1]+s
    s2=s+s[0]
    if checkpa(s1)==1:
        print(s1)
    elif checkpa(s2)==1:
        print(s2)
    else:
        print("NA")
else:
    s1=s[:i]+s[len(s)-1-i]+s[i:]
    s2=s[:len(s)-i]+s[i]+s[len(s)-i:]
    if checkpa(s1)==1:
        print(s1)
    elif checkpa(s2)==1:
        print(s2)
    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)

s=raw_input()
n=len(s)
fl=0
for i in range(n):
	a=''
	for j in range(n):
		if j!=i: a+=s[j]
	if a == a[::-1]:
		fl = 1
		ans=''
		for k in range(n):
			if k == n-i-1:
				if i > n/2:
					ans+=s[i]
					ans+=s[k]
				else:
					ans+=s[k]
					ans+=s[i]
			else: ans+=s[k]
		print ans
		break
if fl == 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")

s=input()
l=len(s)
x=""
flag=0
for i in range(0,l+1):
    for j in range(97,123):
        z=s[0:i]+chr(j)+s[i:]
        y=z[::-1]

        if z==y:
            flag=1
            break
    if flag==1:
        break
if flag==1:
    print(z)
else:
    print("NA")

def pal(s):
	l = 0
	r = len(s) - 1
	while l < r:
		if s[l] != s[r]:
			return False
		l += 1
		r -= 1
	return True

s = input()

l = 0
r = len(s) - 1
f = True
while l < r:
	if s[l] != s[r]:
		s1 = s[:l] + s[r] + s[l:]
		s2 = s[:r + 1] + s[l] + s[r + 1:]
		f = False
		break
	l += 1
	r -= 1

if f:
	p = len(s) // 2
	s1 = s[:p] + s[p] + s[p:]
	s2 = s1

if pal(s1):
	print(s1)
elif pal(s2):
	print(s2)
else:
	print('NA')

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

def is_palin(s):
    return s==s[::-1]

letters='abcdefghijklmnopqrstuvwxyz'
s=raw_input().strip()
res='NA'
for i in letters:
    for j  in range(len(s)+1):
        p=s[:j]+i+s[j:]
        # print p
        if is_palin(p):
            res=p

print res

s = raw_input()
n = len(s)
ans = ""

for x in s:
  if ans != "": break
  for i in range(n+1):
    word = s[:i] + x + s[i:]
    if word == word[::-1]:
      ans = word
      break

if ans == "" : print "NA"
else : print ans

from functools import reduce
from operator import *
from math import *
from sys import *
from string import *
setrecursionlimit(10**7)
RI=lambda: list(map(int,input().split()))
RS=lambda: input().rstrip().split()
#################################################
def isPalindrome(a):
	return a==a[::-1]
x=RS()[0]
for i in range(len(x)+1):
	a,b= x[:i], x[i:]
	for c in ascii_lowercase:
		if(isPalindrome(a+c+b)):
			print(a+c+b)
			exit(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")

if __name__ == '__main__':
    main()

string = list(input())

for i in range(len(string)):
    cur = ord('a')
    for let in range(26):
        ins = chr(cur+let)
        string.insert(i, ins)
        if string == string[::-1]:
            print(''.join(string))
            exit()
        del string[i]
else:
    for let in range(26):
        ins = chr(cur+let)
        string.append(ins)
        if string == string[::-1]:
            print(''.join(string))
            exit()
        del string[len(string) - 1]
    print('NA')

import random
import string

allAlp = string.ascii_letters[:26]

def isPalin(x):
    return x == x[::-1]

def getLen(x):
	return len(x)

def main():
    someInput = str(raw_input())

    if (getLen(someInput) == 1):
        result = someInput*2
    else:
        result = makePalin(someInput)
    return result

def makePalin(x):
    for i in range(getLen(x) + 1):
        for alp in allAlp:
            newString = newStringAtPos(x, i, alp)

            if isPalin(newString):
                return newString

def newStringAtPos(x, pos, newAlp):
    y =  x[:(pos)] + newAlp + x[(pos):]
    return y

result = main()

if result == None:
    print 'NA'
else:
    print result

st1 = input()
a = len(st1)+1
for i in range(26):
    for j in range(a):
        st2 = st1[:j] + chr(i+97) + st1[j:]
        if(st2==st2[::-1]):
            print(st2)
            exit()
print("NA")

def is_pal(s):
    return s == s[::-1]

def main():
    s = raw_input()
    n = len(s)
    for i in xrange(n + 1):
        for j in xrange(26):
            c = chr(ord('a') + j)
            new_word = s[:i] + c + s[i:]
            if is_pal(new_word):
                print new_word
                return
    print "NA"

if __name__ == '__main__':
    main()

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

s = input()

def isPalindrome(l):
    if len(l) == 0 or len(l) == 1:
        return True
    if l[0] != l[-1]:
        return False
    else:
        return isPalindrome(l[1:len(l) - 1])

for i in range(len(s) + 1):
    for j in range(26):
        x = s[0:i] + str(chr(97 + j)) + s[i:]
        if isPalindrome(x):
            print(x)
            quit()

print('NA')

#br = open('a.in')
s = raw_input().strip()
n = len(s)
for i in range(n + 1):
  for j in range(0, 26):
    t = s[:i] + chr(j + 97) + s[i:]
    if t == t[::-1]:
      print t
      exit()
print "NA"

def pal(b):
    size = len(b)
    for i in xrange(size/2):
        if b[i] != b[size-1-i]:
            return False
    return True

a = raw_input()
size = len(a)
alp = ['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']
done = False
for i in xrange(size+1):
    for j in alp:
        if pal(a[:i] + j + a[i:]):
            print a[:i] + j + a[i:]
            done = True
            break
    if done:
        break
if not done:
    print 'NA'

from sys import stdin,stdout
# from collections import deque,Counter,defaultdict
# from itertools import permutations,combinations,combinations_with_replacement
# from operator import itemgetter
# import heapq
# from functools import reduce
def ii():return int(stdin.readline())
def mi():return map(int,stdin.readline().split())
def li():return list(mi())
def si():return stdin.readline()

def ispal(s):
    n = len(s)//2
    if s[:n] == s[-n:][::-1]:
        return True
    else:
        return False

s1 = input()
for  i in range(len(s1)+1):
    for j in range(ord('a'),ord('z')+1):
        s2 = s1[:i] + chr(j) + s1[i:]
        # print(s2)
        if ispal(s2):
            print(s2)
            exit(0)
print('NA')

s=raw_input()
#print s

for i in range(26):
    for j in range(len(s)+1):
        t=s[:j]+chr(i+97)+s[j:]

        if t==t[::-1]:
            print t
            exit(0)
print "NA"

def main():
    l = list(input())
    l.append(None)
    for i in range(len(l) - 1, -1, -1):
        for c in 'abcdefghijklmnopqrstuvwxyz':
            l[i] = c
            if l == l[::-1]:
                print(''.join(l))
                return
        l[i] = l[i - 1]
    print('NA')

if __name__ == '__main__':
    main()

s=list(raw_input())
alphabet=['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']
def loop(s):
    for i in range (len(s)+1):
        for j in alphabet:
            result=True
            ss=s[:i]+[j]+s[i:len(s)]
            for k in range (len(ss)/2+1):
                if ss[k]!=ss[len(ss)-1-k]:
                    result=False
                    break
            if result:
                return ''.join(ss)
    return "NA"
print loop(s)

n=list(raw_input())
for i in xrange(len(n)+1):
    for j in xrange(97,123):
        k=n[:]
        k.insert(i,chr(j))
        chk=''.join(k)
        if chk==chk[::-1]:
            print chk
            exit()
print 'NA'

def palin(word):
	for letter in 'abcdefghijklmnopqrstuvwxyz':
		for i in range(len(word)+1):
			new=word[:i]+letter+word[i:]
			if new[::-1]==new:
				return new
	return 'NA'

word=raw_input()
print palin(word)

def palin(n):
    if(str(n) == str(n)[::-1]):return True
    else: return False
def helpme(s):
    flag=0
    l=len(s)
    till=l/2+(l%2)+1
    for i in range(till):
        if(s[i]!=s[l-1-i]):
            x=s[i:l-1-i]
            y=s[i+1:l-2]
            #print x, y
            if(palin(x)):
                z=s[:i]+s[l-1-i]+s[i:]
                if(palin(z)):
                    print z
                    flag=1
                    return True
                else: return False
            if(flag==0):
                if(palin(y)):
                    z=s[:l-i]+s[i]+s[l-i:]
                    if(palin(z)):
                        print z
                        flag=1
                        return True
                    else: return False
    return False
s=raw_input()
l=len(s)
if(palin(s)):
    if(l%2==0):
        b=s[:l/2]
        #print b
        print b+'a'+b[::-1]
    else:
        b=s[:l/2+1]
        #print b
        print b+b[::-1]
else:
    flag=0
    x=s[1:]
    y=s[:l-1]
    #print x, y
    if(palin(x)):
        print s+s[0]
        flag=1
    if(flag==0):
        if(palin(y)):
            print s[l-1]+s
            flag=1
    if(flag==0):
        if(helpme(s)):flag=1
    if(flag==0):
        print "NA"

def is_palin(s):
	return s == s [::-1]

s = raw_input()
flg = 0
for i in range(97, 97+26):
	for j in range(0, len(s)+1):
		if is_palin(s[:j]+chr(i)+s[j:]):
			print s[:j]+chr(i)+s[j:]
			flg = 1
			break
	if flg==1:
		break

if flg==0:
	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')

def palin(sr):
    sr1=sr[::-1]
    return(sr==sr1)
s=input()
i=0
j=len(s)-1
if(j==0):
    print(s*2)
else:
    while(i<j and s[i]==s[j]):
        i=i+1
        j=j-1
    if(i<j):
        s1=s[0:i]+s[j]+s[i:(j+1)]+s[(j+1):]
        s2=s[0:i]+s[i:(j+1)]+s[i]+s[(j+1):]
        if(palin(s1) or palin(s2)):
            if(palin(s1) and palin(s2)==False):
                print(s1)
            if(palin(s2) and palin(s1)==False):
                print(s2)
            if(palin(s1) and palin(s2)):
                print(s1)
        else:
            print("NA")
    if(i==j):
        s4=s[0:i]+s[i]+s[i]+s[(j+1):]
        print(s4)
    if(i>j):
        s3=s[0:i]+'a'+s[(j+1):]
        print(s3)

word = input().strip()

def testPalindrome(word):
	length = len(word)
	for x in range(int(length/2)):
		if (word[x] != word[length - 1 - x]):
			return False
	return True

def reverseString(word):
	return word[::-1]

def findIndex(word1, word2):
	length = len(word1)
	for i in range(length):
		if (word1[i] != word2[i]):
			return i
	return -1

def findDiffIndex(word):
	newString = ""
	if(len(word) % 2 == 0):
		first, second = word[:int(len(word)/2)], word[int(len(word)/2):][::-1]
		# print(first, second)
		a = findIndex(first, second)
		if (a == -1):
			newString = first + 'x' + second[::-1]
			print(newString)
		else:
			newString = first[:a] + second[a] + first[a:] + second[::-1]
			# print(newString)
			if(testPalindrome(newString)):
				print(newString)
			else:
				newString = first + second[a:][::-1] + first[a] + second[:a][::-1]
				# print(newString)
				if(testPalindrome(newString)):
					print(newString)
				else:
					print('NA')
	else:
		first, second = word[:int(len(word)/2)], word[int(len(word)/2)+1:][::-1]
		a = findIndex(first, second)
		# print(first, second, a)
		midChar = word[int(len(word)/2)]
		if (a == -1):
			newString = first + midChar + midChar + second[::-1]
			print(newString)
		else:
			newString = first[:a] + second[a] + first[a:] + midChar + second[::-1]
			# print(newString)
			if(testPalindrome(newString)):
				print(newString)
			else:
				newString = first + midChar + second[a:][::-1] + first[a] + second[:a][::-1]
				# print(first, second[a:][::-1], midChar, first[a], second[:a][::-1])
				# print(newString)
				if(testPalindrome(newString)):
					print(newString)
				else:
					print('NA')

# print(word)
# print(len(word))

findDiffIndex(word)

import string

def solve(s):
	for i in range(len(s)):
		for x in string.ascii_lowercase:
			t = s[:i] + x + s[i:]
			if t == t[::-1]:
				return t
	for x in string.ascii_lowercase:
			t = s + x
			if t == t[::-1]:
				return t

	return "NA"

s = raw_input()
print solve(s)

def noteven_chars(word):
	chars = {}
	for c in word:
		chars[c] = chars.get(c, 0) + 1
	return [x for x in chars.keys() if chars[x] % 2 == 1]

def combinations(word, c):
	ans = [word[0:x] + c + word[x:] for x in range(0, len(word)+1)]
	return ans

word = raw_input().strip()
noteven = noteven_chars(word)

# at most 1 letter to add + random one in middle
if len(noteven) <= 2:
	noteven.append(word[0])
	valid_words = []
	for c in noteven:
		valid_words.extend(combinations(word, c))

	# The exotic python for-else
	for cw in valid_words:
		if cw == cw[::-1]:
			print(cw)
			break
	else:
		print("NA")
else:
	print("NA")

s=raw_input()
l=len(s)
x=""
flag=0
for i in range(0,l+1):
    for j in range(97,123):
        z=s[0:i]+str(unichr(j))+s[i:]
        y=z[::-1]
        if z==y:
            flag=1
            break
    if flag==1:
        break
if flag==1:
    print z
else:
    print "NA"

#!/usr/bin/env python3

# -----------
# Kitayuta.py
# -----------

"""
A. Mr. Kitayuta's Gift
http://codeforces.com/problemset/problem/505/A/

Mon, 14 Sep 2015
Python 3.4: 77 ms, 500 KB
"""

from string import ascii_lowercase
from sys    import stdin

def is_palindrome(s) :
    return s == s[::-1]

def test_case (s) :
    for i in range(len(s) + 1) :
        j = -i - (1 if (i <= len(s) / 2) else 0)
        c = s[j]
        t = s[:i] + c + s[i:]
        if is_palindrome(t) :
            print(t)
            return
    print("NA")

def main () :
    for s in stdin :
        test_case(s[:-1])

if __name__ == "__main__" :
    main()

s = input()
l = len(s)
for i in range(l + 1):
    cur = s[:i] + s[l - i - 1 + (i > l // 2)] + s[i:]
    if all(cur[i] == cur[l - i] for i in range((l + 1) // 2)):
        print(cur), exit()
print('NA')

import sys

s = raw_input()
n = len(s)

for i in range(0,n+1):
	s1 = s[:i]
	s2 = s[i:]
	for j in range(ord('a'),ord('z')+1):
		temp1 = s1 + chr(j) + s2
		temp2 = temp1[::-1]
		if temp1 == temp2:
			print temp1
			sys.exit()

print "NA"

x = raw_input()
n = len(x)
def isPalin(s):
	k = len(s)
	i = 0
	while i<=k/2:
		if s[i] != s[k-i-1]:
			return 0
		i+=1
	return 1
def dothis(s,c):
	# very bad :-(
	#print "dothis ->",s,c
	for i in range(n+1):
		p = s[:i]+c+s[i:]
		#print "checkingz: ",p
		if(isPalin(p)):
			return p
	#print "This should neverever get printed!!!"
	return "NA"

def doinsane(s):
	mm = set(s)
	for i in mm:
		ans = dothis(s,i)
		if ans != "NA":
			return ans
	return "NA"

def solve(s):
	ss = [s[i] for i in range(n)]
	m = {}
	count = 0
	if n ==1 :
		return s+s
	for i in ss:
		if i in m:
			m.pop(i)
		else:
			m[i] = count
		count+=1

	if(isPalin(s)):
		if n%2:
			if len(m)==1:
				return dothis(s,max(m))
			else:
				return "NA"
		else:
			return s[:n/2]+'a'+s[n/2:]
	else:
		k = len(m)
		if k > 2:
			return "NA"
		if k == 2:
			for i in m:
				ans = dothis(s,i)
				if ans != 'NA':
					return ans
			return "NA"
			"""if n%2 == 0:
				return dothis(s,c)
			else:
				return "NA" """
		if k==1 : # has to be odd
			c = max(m)
			return dothis(s,c)
		if k==0:
			if n%2:
				return "NA"
			else:
				return doinsane(s) #this is harsh
		return "NA" # ???

print solve(x)

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 ispal(st):
    for i in xrange(len(st)):
        if st[i] != st[-(i+1)]:
            return False
    return True

def oneDif(first,second):
#    print first,second
    s1 = ''
    s2 = ''
    if len(first) > len(second):
        s1 = first
        s2 = second
    else:
        s1 = second
        s2 = first
    missing = ''
    pos = 0
    j = len(s2)-1
    for i in xrange(len(s1)):
        if s1[i] == s2[j]:
            j -= 1
        elif len(missing) == 0:
            missing = s1[i]
            pos = j+1
        else:
            return ''
    if len(missing) == 0:
        missing = s1[i]
    res = ''
 #   print missing,pos
    if pos == len(s2):
        res = s2 + missing
    else:
        for i in xrange(len(s2)):
            s = s2[i]
            if i != pos:
                res += s
            else:
                res += missing
                res += s
#        print res,s1,s2
    if first == s1:
        return s1+res
    else:
        return res+s1

s = raw_input()
if len(s) == 2:
    print s + s[0]
else:
    if len(s)%2 == 0:
        if ispal(s):
            print s[:len(s)/2]+'a'+s[len(s)/2:]
        else:
            done = False
            check = [len(s)/2,(len(s)/2)-1]
            for c in check:
                first = s[:c]
                second = s[c+1:]
                res = oneDif(first,second)
                if len(res) > 0:
                    print res[:len(res)/2]+s[c]+res[len(res)/2:]
                    done = True
                    break
            if not done:
                print 'NA'

    else:
        done = False
        if ispal(s):
            mid = len(s)/2
            print s[:mid]+s[mid]+s[mid:]
        else:
            check = [len(s)/2,(len(s)/2)+1]
            for c in check:
                first = s[:c]
                second = s[c:]
   #             print c,first,second
                res = oneDif(first,second)
                if len(res) > 0:
                    print res
                    done = True
                    break
            if not done:
                print 'NA'

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

s = input()

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

from pip._vendor.distlib.compat import raw_input
L = raw_input()
l = 0
r = len(L)-1
flag = 1
ok = 1
gg = -1
while l <= r:
    if L[l] != L[r] and flag == 1:
        flag = 0
        l+=1
        gg = r
    elif L[l] != L[r] and flag == 0:
        ok = 0
        break
    else:
        l+=1
        r-=1
l = 0
r = len(L)-1
if ok == 0:
    ok = 2
    flag = 2
    while l <= r:
        if L[l] != L[r] and flag == 2:
            flag = 0
            r-=1
            gg = l
        elif L[l] != L[r] and flag == 0:
            ok = 0
            break
        else:
            l+=1
            r-=1
if len(L) == 3:
    l = set(L)
    if len(l) == 3:
        ok = 0
if ok == 0:
    print("NA")
    exit()
if gg == -1:
    gg = len(L)//2
gg = int(gg)
if ok == 2:
    for i in range(0,len(L)):
        if(i == gg):
            print(L[len(L)-gg-1],end = '')
        print(L[i],end = '')
if ok == 1:
    for i in range(0,len(L)):
        print(L[i],end = '')
        if(i == gg):
            print(L[len(L)-1-gg],end = '')

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=list(input()),0
a=s[:]
for i in range(len(s)):
    if s[i]!=s[len(s)-1-i]:
        x=1
        a.insert(i,s[len(s)-1-i])
        s.insert(len(s)-i,s[i])
        break
if(x):
    x=0
    for i in range(len(s)):
        if s[i]!=s[len(s)-i-1]:
            x=1
            break
    if(x):
        x=0
        for i in range(len(a)):
            if a[i]!=a[len(a)-i-1]:
                x=1
                break
        if(x):print("NA")
        else:print("".join(a))
    else:print("".join(s))
else:
    s.insert(int(len(s)/2),s[int(len(s)/2)])
    print("".join(s))

a=input()
for i in range(26):
    for j in range(len(a)+1):
        b=a[:j]+chr(97+i)+a[j:]
        if b==b[::-1]:print(b);exit()
print('NA')

def main():
    s = raw_input()
    l = len(s)
    if s == s[::-1]:
        print s[0:l/2]+"y"+s[l/2:]
    else:
        for i in xrange(len(s)):
            if s[i] != s[l-i-1]:
                ns = s[0:i]+s[l-i-1]+s[i:l]
                if ns == ns[::-1]:
                    print ns
                    return
                ns = s[0:l-i]+s[i]+s[l-i:l]
                if ns == ns[::-1]:
                    print ns
                    return
        print "NA"

if __name__ == '__main__':
    main()

def ispal(st):
    for i in xrange(len(st)):
        if st[i] != st[-(i+1)]:
            return False
    return True

def oneDif(first,second):
#    print first,second
    s1 = ''
    s2 = ''
    if len(first) > len(second):
        s1 = first
        s2 = second
    else:
        s1 = second
        s2 = first
    missing = ''
    pos = 0
    j = len(s2)-1
    for i in xrange(len(s1)):
        if s1[i] == s2[j]:
            j -= 1
        elif len(missing) == 0:
            missing = s1[i]
            pos = j+1
        else:
            return ''
    if len(missing) == 0:
        missing = s1[i]
    res = ''
 #   print missing,pos
    if pos == len(s2):
        res = s2 + missing
    else:
        for i in xrange(len(s2)):
            s = s2[i]
            if i != pos:
                res += s
            else:
                res += missing
                res += s
#        print res
    if ispal(s1+res):
        return s1+res
    elif ispal(res+s1):
        return res+s1

s = raw_input()
if len(s) == 2:
    print s + s[0]
else:
    if len(s)%2 == 0:
        if ispal(s):
            print s[:len(s)/2]+'a'+s[len(s)/2:]
        else:
            done = False
            check = [len(s)/2,(len(s)/2)-1]
            for c in check:
                first = s[:c]
                second = s[c+1:]
                res = oneDif(first,second)
                if len(res) > 0:
                    print res[:len(res)/2]+s[c]+res[len(res)/2:]
                    done = True
                    break
            if not done:
                print 'NA'

    else:
        done = False
        if ispal(s):
            mid = len(s)/2
            print s[:mid]+s[mid]+s[mid:]
        else:
            check = [len(s)/2,(len(s)/2)+1]
            for c in check:
                first = s[:c]
                second = s[c:]
   #             print c,first,second
                res = oneDif(first,second)
                if len(res) > 0:
                    print res
                    done = True
                    break
            if not done:
                print 'NA'

import sys

s = input()
list_s = list(s)
# print(list_s)
if s + s[0] == s[0] + s[::-1]:
    print(s + s[0])
    sys.exit()
else:
    for x in range(len(s)):
        polindrom = list_s[:x] + list(s[-(x + 1)]) + list_s[x:]
        if polindrom == polindrom[::-1]:
            print(''.join(polindrom))
            sys.exit()
print('NA')

def main():
    s = raw_input()
    l = len(s)
    if l == 1:
        print s+s
    elif s == s[::-1]:
        print s[0:l/2]+"y"+s[l/2:]
    else:
        for i in xrange(len(s)):
            if s[i] != s[l-i-1]:
                ns = s[0:i]+s[l-i-1]+s[i:l]
                if ns == ns[::-1]:
                    print ns
                    return
                ns = s[0:l-i]+s[i]+s[l-i:l]
                if ns == ns[::-1]:
                    print ns
                    return
        print "NA"

if __name__ == '__main__':
    main()

# -*- coding: utf-8 -*-

import sys
import string

def is_palindrome(s):
    if s == s[::-1]:
        return True
    else:
        return False

def main():
    s = raw_input()
    # print string.ascii_lowercase
    if len(s) == 1:
        print s + s
        sys.exit(0)

    else:
        for c in string.ascii_lowercase:
            new_s = c + s[1:]
            if is_palindrome(new_s):
                print new_s
                sys.exit(0)
            for i in xrange(len(s)):
                new_s = s[:i+1] + c + s[i+1:]
                if is_palindrome(new_s):
                    print new_s
                    sys.exit(0)
        print "NA"

if __name__ == '__main__':
    main()

__author__ = 'Ahmad'
def  is_mot(s):
    j=0
    i=-1
    while j<len(s):
        if s[j]!=s[i]:
            return 0
        i-=1
        j+=1
    else:
        return 1
def main():
    s=raw_input()
    k=s
    j=0
    if is_mot(k)==1:
        if len(k)%2==0:
            print k[0:(len(k)/2)]+'x'+k[(len(k)/2):]
        else:
            print 'NA'
        return 0

    while len(s)>0:
        if s[0]!=s[-1]:
            break
        else:
            s=s[1:-1]
            j+=1
    t=s
    if is_mot(t[1:])==1:
        if j==0:
            print t+t[0]
        else:
            print k[:j]+t+t[0]+k[-j:]
    else:
        if is_mot(t[:-2])==1:
            if j==0:
                print t[-1]+t
            else:
                print k[:j]+t[-1]+t+k[-j:]
        else:
            print 'NA'
    return  0

main()

def is_palindrome(s):
    return s == s[::-1]
s=raw_input("")
y=len(s)-1
x=0
l=list(s)
flag=0
check=0
if len(l)==2 and l[0]!=l[1]:
    l.insert(0,l[1])
    check=1
while x<=y:
    if check==1:
        break
    if l[x]!=l[y]:
        if l[y-1]==l[x]:
            if x==0:
                l.insert(0,l[y])
                s3=''.join(l)
                if is_palindrome(s3):
                    flag=1
                    break
                else:
                    flag=2
                    break
            l.insert(x,l[y-1])
            flag=1
        elif l[y]==l[x+1]:
            l.insert(y+1,l[x])
            flag=1
        else:
            flag=2

        break
    x+=1
    y-=1
if check==1:
    print ''.join(l)
elif flag==0:
    s=str(''.join(l[0:len(l)/2]))+l[len(l)/2]
    if len(l)%2==0:
        l=l[0:len(l)/2]
    else:
        l=l[0:len(l)/2+1]
    l.reverse()
    s=s+str(''.join(l))
    print s
elif flag==1:
    s1=''.join(l)
    print s1
elif flag==2:
    print "NA"

from functools import reduce
from operator import *
from math import *
from sys import *
from string import *
setrecursionlimit(10**7)
RI=lambda: list(map(int,input().split()))
RS=lambda: input().rstrip().split()
#################################################
def isPalindrome(a):
	return a==a[::-1]
x=RS()[0]
for i in range(1,len(x)+1):
	a,b= x[:i], x[i:]
	for c in ascii_lowercase:
		if(isPalindrome(a+c+b)):
			print(a+c+b)
			exit(0)
print("NA")

def is_palindrome(s):
    return str(s) == str(s)[::-1]

def main():
    s = input()

    length = len(s)

    if is_palindrome(s):
        if length % 2 == 0:
            mid = length // 2
            print(s[:mid] + 'a' + s[mid:])
            return
        else:
            mid = (length - 1) // 2
            print(s[:mid] + s[mid] + s[mid:])
            return
    else:
        for index in range(length):
            candidate = s[:index] + s[index + 1:]
            if is_palindrome(candidate):
                if index == 0:
                    print(s + s[index])
                elif index == length - 1:
                    print(s[index] + s)
                else:
                    print(s[:-index] + s[index] + s[-index:])
                return

    print('NA')

if __name__ == '__main__':
    main()

def make_pallindrome(string):
    l = len(string)
    if l == 1:
        return string[0] + string[0]
    elif l % 2 == 0:
        chk = (string[:l/2] == string[l:l/2-1:-1])
        if chk:
            string = string[:l/2] + 'a' + string[l/2:]
            return string
        else:
            string1 = string[:] + string[0]
            string2 = string[-1] + string[:]
            l = len(string1)
            chk1 = (string1[:l/2] == string1[l:l/2:-1])
            chk2 = (string2[:l/2] == string2[l:l/2:-1])
            if chk1:
                return string1
            elif chk2:
                return string2
            else:
                return "NA"
    else:
        chk = (string[:l/2] == string[l:l/2:-1])
        if chk:
            string = string[:l/2 + 1] + string[l/2] + string[l/2+1:]
            return string
        else:
            string1 = string[:] + string[0]
            string2 = string[-1] + string[:]
            l = len(string1)
            chk1 = (string1[:l/2] == string1[l:l/2-1:-1])
            chk2 = (string2[:l/2] == string2[l:l/2-1:-1])
            if chk1:
                return string1
            elif chk2:
                return string2
            else:
                return "NA"

if __name__ == '__main__':
    print make_pallindrome(raw_input())

def isPalin(a):
	return a == a[::-1]

x = raw_input()
s = []
o = []
for i in x:
	s.append(i)
	o.append(i)
l = len(s)
for i in xrange(0, l + 1):
	for j in xrange(0, 26):
		c = ord('a') + j
		s.insert(i, chr(c))
		if isPalin(s):
			x = ''
			for i in s:
				x = x + i
			print x
			exit(0)
		s = o[:]

s = raw_input()
i = 0
j = len(s) - 1
flag = 0
while i < j:
	if s[i] != s[j] and flag == 0:
		if s[i+1] == s[j]:
			a = s[:j+1] + s[i] + s[j+1:]
			b = s[:i] + s[j] + s[i:]
			if a == a[::-1]:
				print a
				flag = 1
				break
			elif b == b[::-1]:
				print b
				flag = 1
				break
			else:
				print "NA"
				flag = 1
				break
	i += 1
	j -= 1
if flag == 0:
	l = len(s)
	if l%2 == 0:
		s = s[:l/2] + 'a' + s[l/2:]
	else:
		c = s[l/2]
		s = s[:l/2] + c + s[l/2:]
	print s

s = list(raw_input())
i = 0
ins = False
while (i < len(s)//2 ):
    n = len(s)
    if s[i] != s[n-1-i]:
        if ins or (i+1)*2==n: print "NA"; exit()
        ins = True
        if s[i] == s[n-2-i]:
            s.insert(i, s[n-1-i])
        else:
            s.insert(n-i, s[i])
    i += 1
if not ins:
    l = s[len(s)//2] if len(s) & 1 else 'y'
    s.insert(len(s)//2, l)
print ''.join(s)

import fileinput

l = None

for line in fileinput.input():
    l = line
    l = line[:-1]

lower_case = range(97,123)

def test_palin(l):
    fir = l[:len(l)/2]
    if len(l) % 2:
        sec = l[:len(l)/2:-1]
    else:
        sec = l[:len(l)/2-1:-1]

    return fir == sec

ret = None

for c in lower_case:
    c = chr(c)
    for x in range(0, len(l)+1):
        test = l[0:x] + c + l[x:]
        if test_palin(test):
            ret = test
            break
    if ret:
    	break

print test

def is_palindrome(word):
    letters = [letter for letter in word]
    j = len(letters) - 1
    for i in xrange(0, len(letters) / 2):
        if letters[i] is not letters[j]:
            return False
        i += 1;
        j -= 1;
    return True

word = raw_input()
letters = [letter for letter in word]
condition_not_met = True
if is_palindrome(word):
    letters.insert(len(letters) / 2, letters[len(letters) / 2])
    print ('').join(letters)
    condition_not_met = False
else:
    for i in xrange(0, len(letters)+1):
        for letter in letters:
            new_word = word[:]
            new_letters = [new_letter for new_letter in new_word]
            new_letters.insert(i, letter)
            new_word = ('').join(new_letters)
            if is_palindrome(new_word):
                print new_word
                condition_not_met = False
                break
            else:
                continue
if condition_not_met:
    print "NA"

s=raw_input("")
y=len(s)-1
x=0
l=list(s)
flag=0
check=0
if len(l)==2 and l[0]!=l[1]:
    check=1

while x<=y:
    if l[x]!=l[y]:
        if l[y-1]==l[x]:
            l.insert(x,l[y-1])
            flag=1
        elif l[y]==l[x+1]:
            l.insert(y+1,l[x])
            flag=1
        else:
            flag=2
            print "NA"
        break
    x+=1
    y-=1
if check==1:
    print "NA"
elif flag==0:
    s=str(''.join(l[0:len(l)/2]))+l[len(l)/2]
    if len(l)%2==0:
        l=l[0:len(l)/2]
    else:
        l=l[0:len(l)/2+1]
    l.reverse()
    s=s+str(''.join(l))
    print s
elif flag==1:
    s1=''.join(l)
    print s1

# coding: utf-8
s = list(input())
length = len(s)
i = 0
j = length-1
while i < j:
    if s[i] == s[j]:
        i += 1
        j -= 1
    else:
        a = s[:j+1] + [s[i]] + s[j+1:]
        b = s[:i+1] + [s[j]] + s[i+1:]
        break
else:
    if len(s)%2==0:
        print(''.join(s[:length//2]+['a']+s[length//2:]))
    else:
        print(''.join(s[:length//2]+[s[length//2]]+s[length//2:]))
    exit()
c = a[::-1]
d = b[::-1]
if a == c:
    print(''.join(a))
elif b == d:
    print(''.join(b))
else:
    print('NA')

string = raw_input()
length = len(string)
FindSolution = 0

if string == string[::-1] :

    if length %2 != 0 :

        FindSolution = 1
        print string[:length/2+1] + string[length/2] + string[length/2+1:]

    else :

        FindSolution = 1
        print string[:length/2] + 'a' + string[length/2:]

else :

    for x in range(0,length) :

        if string.replace(string[x],'',1) == string.replace(string[x],'',1)[::-1] :

            # print string.replace(string[x],''), x

            if x <= length/2 :

                FindSolution = 1
                # print 'hi', x
                print string[:length-x] + string[x] + string[length-x:]
                break

            else :

                FindSolution = 1
                # print length, x
                print string[:length-x-1] + string[x] + string[length-x-1:]
                break

if FindSolution == 0 :

    print 'NA'

# s = 'fft'
# print s.replace(s[0],'j')

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 if len(s) % 2 == 0 else len(s) // 2 + 1)] + "a" + s[len(s) // 2::]
    print(d)

def ispal(st):
    for i in xrange(len(st)):
        if st[i] != st[-(i+1)]:
            return False
    return True

def oneDif(first,second):
    s1 = ''
    s2 = ''
    if len(first) > len(second):
        s1 = first
        s2 = second
    else:
        s1 = second
        s2 = first
    missing = ''
    pos = 0
    j = len(s2)-1
    for i in xrange(len(s1)):
        if s1[i] == s2[j]:
            j -= 1
        elif len(missing) == 0:
            missing = s1[i]
            pos = j+1
        else:
            return ''
    res = ''
    if pos == len(second):
        res = second + missing
    else:
        for i in xrange(len(second)):
            s = second[i]
            if i != pos:
                res += s
            else:
                res += missing
                res += s
    return first+res

s = raw_input()
if len(s)%2 == 0:
    if ispal(s):
        print s[:len(s)/2]+'a'+s[len(s)/2:]
    else:
        done = False
        check = [len(s)/2,(len(s)/2)-1]
        for c in check:
            first = s[:c]
            second = s[c+1:]
            res = oneDif(first,second)
            if len(res) > 0:
                print res[:len(res)/2]+s[c]+res[:len(res)/2]
                done = True
                break
        if not done:
            print 'NA'

else:
    if ispal(s):
        mid = len(s)/2
        print s[:mid]+s[mid]+s[mid:]
    else:
        check = [len(s)/2,(len(s)/2)-1]
        for c in check:
            first = s[:c]
            second = s[c:]
            res = oneDif(first,second)
            if len(res) > 0:
                print res
                done = True
                break
        if not done:
            print 'NA'

alph = list("abcdefghijklmnopqrstuvwxyz")
def pal(s):
        l = len(s) - 1
        f = 1
        for i in range(int(l / 2)):
                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):
        print(st)
else:
        print("NA")

s = raw_input()
n = len(s)
def f(s):
	n = len(s)
	for i in range(n):
		if s[i] != s[n-1-i]: return False
	return True

if f(s):
	s = s[0:n/2]+'y'+s[n/2:]
	print s
	exit()

flag = False
for a in range(n/2+1):
	if s[a] != s[n-1-a]:
		t = s[0:n-a]
		t += s[a]
		t += s[n-a:]
		if f(t):
			print t
			flag = True

if flag == False:
	print "NA"

# быстро жадно но криво
s=input()

for i in range(len(s)):
    for j in range(26):
        z=s[:i]+chr(ord('a')+j)+s[i:]
        if z==z[::-1]:
            print(z)
            halt()
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):
    get_palindrome(word, x)

if not found:
    print('N/A')

s=raw_input()
n=len(s)
fl=0
for i in range(n):
	a=''
	for j in range(n):
		if j!=i: a+=s[j]
	if a == a[::-1]:
		fl = 1
		# print a
		ans=''
		for k in range(n):
			if k == n-i-1:
				ans+=s[k]
				ans+=s[i]
			else: ans+=s[k]
		print ans
		break
if fl == 0: print 'NA'

import sys

def isPalindrome(l):
	return l == list(reversed(l))

s = list(sys.stdin.readline())[0:-1]
largo = len(s)
solution = ['N','A']
for j in range(largo):
	test = list(s)
	test[j:j] =[test[largo-1-j]]
	if isPalindrome(test):
		solution = test

test = list(s)
test[largo:largo] = test[0]
if isPalindrome(test):
	solution = test

print "".join(solution)

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)
        ctr = 0
        for char in alp:
            while ctr <= length:
                new = a[:ctr] + char + a[ctr:]
                if pal(new):
                    p = new
                ctr+=1

        print(p)

def make_palindrome(s):
    if len(s) == 0:
        return 'a'
    if len(s) == 1:
        return s+s
    i,j = 0,len(s)-1
    s = list(s)
    new_wrd = None
    while i < j:
        if s[i] != s[j]:
            new_wrd = True
            break
        i += 1
        j -= 1
    if new_wrd is not None:
        new_wrd = s[:j+1]+[s[i]]+s[j+1:]
        #print(new_wrd)
        if  ''.join(new_wrd) == ''.join(new_wrd)[::-1]:
            return ''.join(new_wrd)
        else:
            new_wrd = s[:i]+[s[j]]+s[i:]
            #print(new_wrd)
            if  ''.join(new_wrd) == ''.join(new_wrd)[::-1]:
                return ''.join(new_wrd)
            return 'NA'
    else:
        if i == j:
            new_wrd = s[:i+1]+[s[j]]+s[j:]
        else:
            new_wrd = s[:j+1]+['a']+s[i:]
        return ''.join(new_wrd)

if __name__ =='__main__':
    s = input()
    print(make_palindrome(s))

x = input()
d = False
for c in range(97,123):
    if ( d):
        break
    for i in range(len(x) + 1):
        n = x[:i] + chr(c) + x[i:]
        if n == n[::-1]:
            print (n)

            d= True
            break

import copy
def f(n):
    l=len(n)/2
    inserted=False
    for i in range(l):
        if n[i]!=n[len(n)-i-1]:
            n.insert(len(n)-i,n[i])
            inserted=True
            break
    if inserted==True:
        l=len(n)/2
        flag=True
        for i in range(l):
            if n[i]!=n[len(n)-i-1]:
                flag=False
                break
        if flag:
            return ''.join(n)
        else:
            return 'NA'
    else:
        n.insert(len(n)/2,'a')
        return ''.join(n)

if __name__ == '__main__':
    r=list(raw_input())
    rr=copy.copy(r)
    ans1=f(r)
    rr.reverse()
    ans2=f(rr)
    if ans1==ans2=='NA':
        print 'NA'
    else:
        if ans1!='NA':
            print ans1
        else:
            print ans2

s=list(input())
p=s.copy()
o=1
for i in range(len(s)):
    s=p.copy()
    s.insert(len(s)-i, s[i])
    if(s == s[::-1]):
        for l in s:
            print(l, end='')
        o=0
        break
if(o):
    print("Na")

def palin(n):
    if(str(n) == str(n)[::-1]):return True
    else: return False
def helpme(s):
    flag=0
    l=len(s)
    till=l/2+(l%2)+1
    for i in range(till):
        if(s[i]!=s[l-1-i]):
            x=s[i:l-1-i]
            y=s[i+1:l-2]
            #print x, y
            if(palin(x)):
                z=s[:i]+s[l-1-i]+s[i:]
                if(palin(z)):
                    print z
                    flag=1
                    return True
                else: return False
            if(flag==0):
                if(palin(y)):
                    z=s[:l-i]+s[i]+s[l-i:]
                    if(palin(z)):
                        print z
                        flag=1
                        return True
                    else: return False
    return False
s=raw_input()
l=len(s)
if(palin(s)):
    if(l%2==0):
        b=s[:l/2]
        print b
        print b+'a'+b[::-1]
    else:
        b=s[:l/2+1]
        print b
        print b+b[::-1]
else:
    flag=0
    x=s[1:]
    y=s[:l-1]
    #print x, y
    if(palin(x)):
        print s+s[0]
        flag=1
    if(flag==0):
        if(palin(y)):
            print s[l-1]+s
            flag=1
    if(flag==0):
        if(helpme(s)):flag=1
    if(flag==0):
        print "NA"

def pal(a):
    size = len(a)
    for i in xrange(size/2 + 1):
        if a[i] != a[size-1-i]:
            return False
    return True

a = raw_input()
size = len(a)
if pal(a):
    print a[:size/2] + 'a' + a[size/2:]
else:
    alp = ['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']
    done = False
    for i in xrange(size+1):
        for j in alp:
            if pal(a[:i] + j + a[i+1:]):
                print a[:i] + j + a[i+1:]
                done = True
                break
        if done:
            break
    if not done:
        print 'NA'

s=input()
if "".join(reversed(s))==s:
    if len(s)%2==0:
        print(s[:len(s)//2]+'l'+s[len(s)//2:])
    else:
        print(s[:len(s)//2]+s[len(s)//2]+s[len(s)//2:])
    exit()
n=len(s)
st=s[n-1]+s
if st=="".join(reversed(st)):
    print(st)
    exit()
st=s+s[0]
if st=="".join(reversed(st)):
    print(st)
    exit()
a=[0]*(n+1)
flag=0
i=0
j=n-1
f=0
l=n
while(i<=j):
    if s[i]==s[j]:
        a[f]=s[i]
        f+=1
        a[l]=s[j]
        l-=1
        i+=1
        j-=1
    elif s[i]!=s[j] and flag==0:
        a[f]=s[i]
        f+=1
        a[l]=s[i]
        l-=1
        i+=1
        flag=1
    elif s[i]!=s[j] and flag:
        print("NA")
        exit()
print("".join(str(e) for e in a))

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

def is_palindrome(word):
    letters = [letter for letter in word]
    j = len(letters) - 1
    for i in xrange(0, len(letters) / 2):
        if letters[i] is not letters[j]:
            return False
        i += 1;
        j -= 1;
    return True

word = raw_input()
letters = [letter for letter in word]
new_word = ''
if is_palindrome(word):
    letters.insert(len(letters) / 2, letters[len(letters) / 2])
    print ('').join(letters)
else:
    for i in xrange(0, len(letters)+1):
        for letter in letters:
            new_word = word[:]
            new_letters = [new_letter for new_letter in new_word]
            new_letters.insert(i, letter)
            new_word = ('').join(new_letters)
            if is_palindrome(new_word):
                print new_word
                break
            else:
                continue
if not is_palindrome(new_word):
    print "NA"

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:
                if ctr == 0:
                    new = char + a
                else:
                    new = a[:ctr] + char + a[ctr:]
                if pal(new):
                    p = new
                ctr+=1

        print(p)

s = input()
al = 'abcdefghijklmnopqrstuvwxyz'
ans = False
for i in range(26): ### it's just a o(1)
    for j in range(len(s)+1):
        tmp = s[:j]+al[i]+s[j:]
        if tmp == tmp[::-1]:
            print(tmp )
            ans = True
    if ans :
        break
if not ans:
    print('NA')

def process(left, right, chars, inserted):
    if left > right:
        if not inserted:
            chars.insert(left, 'a')
        return True
    if left == right:
        if not inserted:
            chars.insert(left, chars[left])
        return True

    if chars[left] == chars[right]:
        return process(left + 1, right - 1, chars, inserted)

    # discrepancy happens
    if inserted:
        return False

    if chars[left + 1] == chars[right]:
        chars.insert(right + 1, chars[left])
        inserted = True
        return process(left + 2, right - 1, chars, inserted)
    elif chars[left] == chars[right - 1]:
        chars.insert(left, chars[len(chars) - 1])
        inserted = True
        return process(left + 2, right - 1, chars, inserted)
    else:
        return False

chars = list(raw_input())
if process(0, len(chars) - 1, chars, False):
    print ''.join(chars)
else:
    print 'NA'

def is_palindrome(s):
    return s == s[::-1]
s=raw_input("")
y=len(s)-1
x=0
l=list(s)
flag=0
check=0
if len(l)==2 and l[0]!=l[1]:
    l.insert(0,l[1])
    check=1
while x<=y:
    if check==1:
        break
    if l[x]!=l[y]:
        if l[y-1]==l[x]:
            if x==0:
                l.insert(0,l[y])
                s3=''.join(l)
                if is_palindrome(s3):
                    flag=1
                    break
                else:
                    flag=2
                    break
            l.insert(x,l[y-1])
            flag=1
        elif l[y]==l[x+1]:
            l.insert(y+1,l[x])
            s3=''.join(l)
            if is_palindrome(s3):
                flag=1
                break
            else:
                flag=2
                break
            flag=1
        else:
            flag=2

        break
    x+=1
    y-=1
if check==1:
    print ''.join(l)
elif flag==0:
    s=str(''.join(l[0:len(l)/2]))+l[len(l)/2]
    if len(l)%2==0:
        l=l[0:len(l)/2]
    else:
        l=l[0:len(l)/2+1]
    l.reverse()
    s=s+str(''.join(l))
    print s
elif flag==1:
    s1=''.join(l)
    print s1
elif flag==2:
    print "NA"

s=input()
si=s[::-1]
if s==si and len(s)%2==0:
    output=s[:len(s)//2]+"a"+s[len(s)//2:]
    print(output)
elif s==si and len(s)%2==1:
    output=s[:len(s)//2+1]+s[len(s)//2:]
    print(output)
else:
    output=""
    save=-1
    for i in range(len(s)):
        if s[i]!=si[i]:
            output+=s[i]
            save=i
            break
        else:
            output+=s[i]
    if save>-1 and save<len(s):
        output+=si[save:]
    if output!=output[::-1]:
        print("NA")
        '''print(output)'''
    else:
        print(output)

s = str(input())
s = list(s)
s1 = s[::-1]
answer = ""
output = s
if len(s) == 1:
    s += s
    output = list(s)
elif s == s1:
    for element in s:
        s.insert(int(len(s)/2), element)
        if s == s[::-1]:
            break
        else:
            s.pop(int(len(s) / 2))
    output = s
else:
    for letter in s:
        count = 0
        while count <= len(s):
            s.insert(count, letter)
            s1 = s[::-1]
            if s1 == s:
                output = s1
            s.pop(count)
            count += 1

if output == output[::-1]:
    for letter in output:
        answer += letter
    print (answer)
else:
    print ("NA")

s=raw_input()
l=len(s)
t=s[::-1]
flag=1
for i in xrange(l):
	if(s[i]!=t[i]):
		flag=0
		t=t[:i]+s[i]+t[i:]
		s=s[:l-i]+s[i]+t[l-i+1:]
		break
if(flag):
	if(l%2):
		print s[:l/2]+s[l/2]+s[l/2:]
	else:
		print s[:l/2]+"z"+s[l/2:]
else:
	if(t==s):
		print s
	else:
		print "NA"

x = raw_input()
n = len(x)
def isPalin(s):
	k = len(s)
	i = 0
	while i<=k/2:
		if s[i] != s[k-i-1]:
			return 0
		i+=1
	return 1
def dothis(s,c):
	# very bad :-(
	#print "dothis ->",s,c
	for i in range(n+1):
		p = s[:i]+c+s[i:]
		#print "checkingz: ",p
		if(isPalin(p)):
			return p
	#print "This should neverever get printed!!!"
	return "NA"

def solve(s):
	ss = [s[i] for i in range(n)]
	m = {}
	count = 0
	if n ==1 :
		return s+s
	for i in ss:
		if i in m:
			m.pop(i)
		else:
			m[i] = count
		count+=1

	if(isPalin(s)):
		if n%2:
			if len(m)==1:
				return dothis(s,max(m))
			else:
				return "NA"
		else:
			return s[:n/2]+'a'+s[n/2:]
	else:
		k = len(m)
		if k > 2:
			return "NA"
		if k == 2:
			c = max(m)
			if n%2 == 0:
				return dothis(s,c)
			else:
				return "NA"
		if k==1 : # has to be odd
			c = max(m)
			return dothis(s,c)
		return "NA" # ???

print solve(x)

s = list(raw_input())
for i,j in enumerate(s):
    for a in 'abcdefghijklmnopqrstuvwxyz':
        c = s[:i+1] + [a] + s[i+1:]
        if c == c[::-1]:
            print ''.join(c)
            exit(0)
print "NA"

from math import floor
s=input()
ls=len(s)
if ls==1:
    print('NA')
    exit()
for i in range (floor(ls/2)):
    isp=0
    if s[i]!=s[ls-i-1]:
        isp=1
        sn=s[:i]+s[ls-i-1]+s[i:]
        #print(sn)
        csn=0
        for j in range (floor(len(sn)/2)):
            if sn[j]!=sn[-j-1]:
                csn=1
                break
        if csn:
            csn=0
            sn=s[:ls-i]+s[i]+s[ls-i:]
            #print(sn)
            for j in range (floor(len(sn)/2)):
                if sn[j]!=sn[-j-1]:
                    csn=1
                    break
        break
if isp:
    if csn:
        print('NA')
    else:
        print(sn)
else:
    if ls%2==1:
        print('NA')
    else:
        print(s[:floor(ls/2)]+'a'+s[floor(ls/2):])

s = list(input())
l = len(s)
le = s[:l//2]
ri = s[l//2:]

if l&1:
    if le == ri[1:][::-1]:
        print("".join(le+ri[:1]*2+ri[1:]))
    else:
        l = le.copy()
        l.insert(0, ri[-1])
        if l == ri[::-1]:
            print("".join(l+ri))
        else:
            le += ri[1:]
            r = ri[1:]
            r.insert(len(r), le[0])
            if le == r[::-1]:
                print("".join(le+r))
            else:
                print("NA")
else:
    if le[0] != ri[l//2-1]:
        ri = ri[1:]
        ri.append(le[0])
        if le == ri[::-1]:
            print("".join(le+s[l//2:l//2+1]+ri))
        else:
            print("NA")
    elif le == ri[::-1]:
        print("".join(le+["z"]+ri))
    else:
        print("NA")

def make_pallindrome(string):
    l = len(string)
    if l == 1:
        return string[0] + string[0]
    elif l % 2 == 0:
        chk = (string[:l/2] == string[l:l/2-1:-1])
        if chk:
            string = string[:l/2] + 'a' + string[l/2:]
            return string
        else:
            string = string[:] + string[0]
            l = len(string)
            chk = (string[:l/2] == string[l:l/2:-1])
            if chk:
                return string
            else:
                return "NA"
    else:
        chk = (string[:l/2] == string[l:l/2:-1])
        if chk:
            string = string[:l/2 + 1] + string[l/2] + string[l/2+1:]
            return string
        else:
            return "NA"

if __name__ == '__main__':
    print make_pallindrome(raw_input())

def check(s,n):
    ans=""
    for i in range(int(n/2)):
        if(s[i]!=s[n-1-i]):
            ans=s[:n-i]+s[i]+s[n-i:]
            break
    if(ans==ans[::-1]):
        print(ans)
    else:
        print("NA")

s=input()
n=len(s)
if(s==s[::-1]):
    print(s[:int(n/2)],s[int(n/2)],s[int(n/2):],sep="")
else:
    check(s,n)

s = list(raw_input())
i = 0
ins = False
while (i < len(s)//2 ):
    n = len(s)
    if s[i] != s[n-1-i]:
        if ins or (i+1)*2==n: print "NA"; exit()
        ins = True
        if s[i] == s[n-2-i]:
            s.insert(i, s[n-1-i])
        else:
            s.insert(n-i, s[i])
    i += 1
if not ins:
    l = s[len(s)//2] if len(s) & 1 else 'y'
    s.insert(len(s)//2, l)
print ''.join(s)

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 or len(s) == 1:
    print("NA")
else:
    d = s[:(len(s) // 2 if len(s) % 2 == 0 else len(s) // 2 + 1)] + "a" + s[len(s) // 2::]
    print(d)

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) - 1 - a] + s[a] + s[len(s) - 1 - 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) - 1 - i] + s[i] + s[len(s) - 1 - i::]
            print(q)
            exit(0)
        else:
            p = True
            break
if p:
    print("NA")
else:
    d = s[:(len(s) // 2 if len(s) % 2 == 0 else len(s) // 2 + 1)] + "a" + s[len(s) // 2::]
    print(d)

s = raw_input()
n = len(s)
def f(s):
	n = len(s)
	for i in range(n):
		if s[i] != s[n-1-i]: return False
	return True

if f(s):
	s = s[0:n/2]+'y'+s[n/2:]
	print s
	exit()

flag = False
for a in range(n/2+1):
	if s[a] != s[n-1-a]:
		t = s[0:n-a]
		t += s[a]
		t += s[n-a:]
		if f(t):
			print t
			flag = True

if flag == False:
	print "NA"

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

def main():
    s = raw_input()
    l = len(s)
    if l == 1:
        print s+s
    elif s == s[::-1]:
        print s[0:l/2]+"y"+s[l/2:]
    else:
        for i in xrange(len(s)):
            if s[i] != s[l-i-1]:
                ns = s[0:i]+s[l-i-1]+s[i:l]
                if ns == ns[::-1]:
                    print ns
                    return
                ns = s[0:l-i]+s[i]+s[l-i:l]
                if ns == ns[::-1]:
                    print ns
                    return
        print "NA"

if __name__ == '__main__':
    main()

# быстро жадно но криво
s=input()

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

s = raw_input()
i = 0
j = len(s) - 1
flag = 0
while i < j:
	#print i, j, s
	if s[i] != s[j] and flag == 0:
		if s[i+1] == s[j]:
			s = s[:j+1] + s[i] + s[j+1:]
			flag = 1
			i += 1
		elif s[j-1] == s[i]:
			#print "yes"
			s = s[:i] + s[j] + s[i:]
			flag = 1
			i += 1
		else:
			flag = 2
			print "NA"
			break

	elif s[i] != s[j] and flag == 1:
		flag = 2
		print "NA"
		break
	else:
		i += 1
		j -= 1
if flag == 1:
	print s
elif flag == 0:
	l = len(s)
	if l%2 == 0:
		s = s[:l/2] + 'a' + s[l/2:]
	else:
		c = s[l/2]
		s = s[:l/2] + c + s[l/2:]
	print s

st = list(input())

for i in range(1, 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')

def make_palindrome(s):
    if len(s) == 0:
        return 'a'
    if len(s) == 1:
        return s+s
    i,j = 0,len(s)-1
    s = list(s)
    new_wrd = None
    while i < j:
        if s[i] != s[j]:
            new_wrd = True
            break
        i += 1
        j -= 1
    if new_wrd is not None:
        new_wrd = s[:j+1]+[s[i]]+s[j+1:]
        print(new_wrd)
        if  ''.join(new_wrd) == ''.join(new_wrd)[::-1]:
            return ''.join(new_wrd)
        else:
            new_wrd = s[:i]+[s[j]]+s[i:]
            print(new_wrd)
            if  ''.join(new_wrd) == ''.join(new_wrd)[::-1]:
                return ''.join(new_wrd)
            return 'NA'
    else:
        if i == j:
            new_wrd = s[:i+1]+[s[j]]+s[j:]
        else:
            new_wrd = s[:j+1]+['a']+s[i:]
        return ''.join(new_wrd)

if __name__ =='__main__':
    s = input()
    print(make_palindrome(s))

import fileinput, math, collections

###          ###
# utility func #
###          ###

dbug = True

def btos(b):
	return 'YES' if b else 'NO'

def pd(s, label=''):
	global dbug
	if dbug:
		header = 'debug:'
		if label != '':
			header += ' (%s)\t' % label
		print header, s

def stoi(s):
	return([ int(x) for x in s.split() ])

def perm(n, k, wheels=True):
	if wheels:
		assert(n > 0)
		assert(k > 0)
	return math.factorial(n) / math.factorial(k)

def comb(n, k, wheels=True):
	if wheels:
		assert(n > 0)
		assert(k > 0)
		assert(n - k > 0)
	return perm(n, k, False) / math.factorial(n - k)

def tol(actual, expected, tolerance=10 ** -9):
	if type(actual) != type([]):
		(actual, expected) = ([ actual ], [ expected ])
	if len(actual) != len(expected):
		return False
	r = [ expected[i] - tolerance <= actual[i] <= expected[i] + tolerance for i in xrange(len(actual)) ]
	return sum(r) == len(r)

def btod(b):
	return b * 2 - 1

def _sigma(f):
	return f * (f + 1) / 2

# sum(x from i to f)
def sigma(i, f, wheels=True):
	if wheels:
		assert(i >= 0)
		assert(f >= 0)
	return _sigma(f) - _sigma(i - 1)

def ps(l, wheels=True):
	if wheels:
		assert(len(l) > 0)
	r = [ l[0] ] * len(l)
	for i in xrange(1, len(l)):
		r[i] = l[i] + r[i - 1]
	return r

def test_utilities():
	assert(stoi('1 2 3\n') == [ 1, 2, 3 ])
	assert(stoi('') == stoi('\n') == [])
	assert(perm(10, 5) == 30240)
	assert(comb(10, 5) == 252)
	assert(tol(0.0, 0.0) == tol(0.0, 0.1, tolerance=0.1) == tol(0.0, 10, tolerance=10) == True)
	assert(tol(0.0, 0.1) == tol(0.0, 0.1, tolerance=0.1 - 10 ** -9) == False)
	assert(tol([ 1.0, 1.1 ], [ 2.0, 2.1 ], tolerance=1) == True)
	assert(tol([ 1, 2 ], [ 1 ]) == tol([ 1 ], [ 1, 2 ]) == False)
	assert(_sigma(1) == 1)
	assert(_sigma(10) == 55)
	assert(sigma(1, 10) == 55)
	assert(sigma(3, 10) == 52)
	assert(sigma(10, 10) == 10)
	assert(sigma(10, 11) == 21)
	assert(ps([ 1 ]) == [ 1 ])
	assert(ps([ 1, 2, 3, 4, 5 ]) == [ 1, 3, 6, 10, 15 ])
	assert(btod(0) == -1)
	assert(btod(1) == 1)
	assert(btos(True) == 'YES')
	assert(btos(False) == 'NO')

###          ###
# code follows #
###          ###

# args = [ 'line 1', 'line 2', ... ]
def proc_input(args):
	return args[0].strip()

def solve(args, verbose=False):
	s = proc_input(args)
	p = s[::-1]
	c = 0
	n = len(s) / 2
	l = s[n]
	if len(s) > 2:
		for k in xrange(len(p) / 2 + 1):
			if c > 1:
				break
			if s[k + c] != p[k]:
				(n, l) = (len(p) - k, s[k])
				c += 1
	elif len(s) == 2:
		(n, l) = (2, s[0])
	succ = c < 2
	if succ:
		s = s[:n] + l + s[n:]
	if verbose:
		print s if succ else 'NA'
	return s if succ else False

def test():
	assert(solve([ 'revive' ], verbose=True) == 'reviver')
	assert(solve([ 'ee' ], verbose=True) == 'eee')
	assert(solve([ 'blah' ], verbose=True) == False)
	assert(solve([ 'e' ], verbose=True) == 'ee')
	assert(solve([ 'ef' ], verbose=True) == 'efe')
	assert(solve([ 'kitayuta' ], verbose=True) == False)

if __name__ == '__main__':
	from sys import argv
	if argv.pop() == 'test':
		test_utilities()
		test()
	else:
		dbug = False
		solve(list(fileinput.input()), verbose=True)

s=input()
if "".join(reversed(s))==s:
    if len(s)%2==0:
        print(s[:len(s)//2]+'l'+s[len(s)//2:])
    else:
        print(s[:len(s)//2]+s[len(s)//2]+s[len(s)//2:])
    exit()
n=len(s)
a=[0]*(n+1)
flag=0
i=0
j=n-1
f=0
l=n
while(i<=j):
    if s[i]==s[j]:
        a[f]=s[i]
        f+=1
        a[l]=s[j]
        l-=1
        i+=1
        j-=1
    elif s[i]!=s[j] and flag==0:
        a[f]=s[i]
        f+=1
        a[l]=s[i]
        l-=1
        i+=1
        flag=1
    elif s[i]!=s[j] and flag:
        print("NA")
        exit()
print("".join(str(e) for e in a))

import fileinput, math, collections

###          ###
# utility func #
###          ###

dbug = True

def btos(b):
	return 'YES' if b else 'NO'

def pd(s, label=''):
	global dbug
	if dbug:
		header = 'debug:'
		if label != '':
			header += ' (%s)\t' % label
		print header, s

def stoi(s):
	return([ int(x) for x in s.split() ])

def perm(n, k, wheels=True):
	if wheels:
		assert(n > 0)
		assert(k > 0)
	return math.factorial(n) / math.factorial(k)

def comb(n, k, wheels=True):
	if wheels:
		assert(n > 0)
		assert(k > 0)
		assert(n - k > 0)
	return perm(n, k, False) / math.factorial(n - k)

def tol(actual, expected, tolerance=10 ** -9):
	if type(actual) != type([]):
		(actual, expected) = ([ actual ], [ expected ])
	if len(actual) != len(expected):
		return False
	r = [ expected[i] - tolerance <= actual[i] <= expected[i] + tolerance for i in xrange(len(actual)) ]
	return sum(r) == len(r)

def btod(b):
	return b * 2 - 1

def _sigma(f):
	return f * (f + 1) / 2

# sum(x from i to f)
def sigma(i, f, wheels=True):
	if wheels:
		assert(i >= 0)
		assert(f >= 0)
	return _sigma(f) - _sigma(i - 1)

def ps(l, wheels=True):
	if wheels:
		assert(len(l) > 0)
	r = [ l[0] ] * len(l)
	for i in xrange(1, len(l)):
		r[i] = l[i] + r[i - 1]
	return r

def test_utilities():
	assert(stoi('1 2 3\n') == [ 1, 2, 3 ])
	assert(stoi('') == stoi('\n') == [])
	assert(perm(10, 5) == 30240)
	assert(comb(10, 5) == 252)
	assert(tol(0.0, 0.0) == tol(0.0, 0.1, tolerance=0.1) == tol(0.0, 10, tolerance=10) == True)
	assert(tol(0.0, 0.1) == tol(0.0, 0.1, tolerance=0.1 - 10 ** -9) == False)
	assert(tol([ 1.0, 1.1 ], [ 2.0, 2.1 ], tolerance=1) == True)
	assert(tol([ 1, 2 ], [ 1 ]) == tol([ 1 ], [ 1, 2 ]) == False)
	assert(_sigma(1) == 1)
	assert(_sigma(10) == 55)
	assert(sigma(1, 10) == 55)
	assert(sigma(3, 10) == 52)
	assert(sigma(10, 10) == 10)
	assert(sigma(10, 11) == 21)
	assert(ps([ 1 ]) == [ 1 ])
	assert(ps([ 1, 2, 3, 4, 5 ]) == [ 1, 3, 6, 10, 15 ])
	assert(btod(0) == -1)
	assert(btod(1) == 1)
	assert(btos(True) == 'YES')
	assert(btos(False) == 'NO')

###          ###
# code follows #
###          ###

# args = [ 'line 1', 'line 2', ... ]
def proc_input(args):
	return args[0].strip()

def solve(args, verbose=False):
	s = proc_input(args)
	p = s[::-1]
	c = 0
	for k in xrange(len(s) / 2):
		if s[k] != p[k]:
			c += 1
			p = p[:k] + s[k] + p[k:]
	if c == 0:
		p = p[len(s) / 2:] + p[len(s) / 2] + p[:len(s) / 2]
	succ = c < 2
	if verbose:
		print p if succ else 'NA'
	return p if succ else False

def test():
	assert(solve([ 'revive' ], verbose=True) == 'reviver')
	assert(solve([ 'ee' ], verbose=True) == 'eee')
	assert(solve([ 'blah' ], verbose=True) == False)
	assert(solve([ 'e' ], verbose=True) == 'ee')
	assert(solve([ 'ef' ], verbose=True) == 'efe')
	assert(solve([ 'kitayuta' ], verbose=True) == False)

if __name__ == '__main__':
	from sys import argv
	if argv.pop() == 'test':
		test_utilities()
		test()
	else:
		dbug = False
		solve(list(fileinput.input()), verbose=True)

s = input()
n = len(s)
i, j = 0, n-1
cnt = 0
if s == s[::-1]:
    k = n//2
    print(s[:k+1] + s[k:])
    exit()
while(i < j):
    if s[i] == s[j]:
        i += 1
        j -= 1
    else:
        s = s[:j+1] + s[i] + s[j+1:]
        i += 1
        if len(s) > n + 1: print('NA'); exit()
if n + 1 != len(s) and n != len(s):
    print('NA')
else:
    print(s)

def lol():
    s=raw_input()
    s=list(s)
    start=0
    end=s.__len__()-1
    flag=0
    k=0

    while(start<end):
        if(s[start]!=s[end]):
            if flag==1:
                print "NA"
                k=1
                break
            else:
                s.insert(end+1,s[start])
                end=end+1
                flag=1
        if(end-start==1 and k==0):
            s.insert(start+1,'y')
        start=start+1
        end=end-1
    if s.__len__()==1:
        s.append(s[0])

    if k==0:
        print ''.join(s)

lol()

def ispalindrome(s):
    if(s == s[::-1]):
        return True
    else:
        return False

s =  input()
z = list(s)
if(ispalindrome(s)):
    if(len(z) % 2 == 0):
        z.insert(len(z)//2, "q")
    else:
        z.insert(len(z)//2, z[len(z) // 2])
    z = "".join(z)
    print(z)
else:
    s = list(s)
    k = s.copy()
    for i in range(len(s)):
        if(s.count(s[i]) == 1):
            k.insert(len(s) - i - 1, s[i])
            break

    k = ''.join(k)
    print(k)
    if(ispalindrome(k)):
        print(k)
    else:
        print("NA")

    #print(*k)

import os

def isAlreadyPalindrome(word):
    reverseWord = list(word)
    reverseWord.reverse()
    rWord = "".join(reverseWord)
    return word == rWord
def addAlphabet(word):
    newWord = word
    mid = len(word) / 2
    if len(word) % 2 == 0:
        newWord = word[0:mid] + 'a' + word[mid:]
    else:
        newWord = word[0:mid] + word[mid] + word[mid:]
    return newWord
word = raw_input()
i = 0
j= len(word) - 1
formedPalindrome = False
if isAlreadyPalindrome(word) == True:
    print addAlphabet(word)
else:
    while i < j:
        if word[i] == word[j]:
            i += 1
            j -= 1
        else:
            tempword = word[0:j] + word[j] + word[i]
            if j < len(word) -1:
                tempword += word[j+1:]
            if isAlreadyPalindrome(tempword) == True:
                print tempword
                break;
            else:
                print "NA"
                break;

s = raw_input()
i = 0
j = len(s) - 1
flag = 0
while i < j:
	if s[i] != s[j] and flag == 0:
		if s[i+1] == s[j]:
			s = s[:j+1] + s[i] + s[j+1:]
			flag = 1
			i += 1
		elif s[j-1] == s[i]:
			s = s[:i] + s[j] + s[i:]
			flag = 1
			j -= 1
		else:
			flag = 2
			print "NA"
			break

	elif s[i] != s[j] and flag == 1:
		flag = 2
		print "NA"
		break
	else:
		i += 1
		j -= 1
if flag == 1:
	print s
elif flag == 0:
	l = len(s)
	if l%2 == 0:
		s = s[:l/2] + 'a' + s[l/2:]
	else:
		c = s[l/2]
		s = s[:l/2] + c + s[l/2:]
	print s

def ispalindrome(s):
    if(s == s[::-1]):
        return True
    else:
        return False

s =  input()
z = list(s)
if(ispalindrome(s)):
    if(len(z) % 2 == 0):
        z.insert(len(z)//2, "q")
    else:
        z.insert(len(z)//2, z[len(z) // 2])
    z = "".join(z)
    print(z)
else:
    s = list(s)
    k = s.copy()
    for i in range(len(s)):
        if(s.count(s[i]) == 1):
            k.insert(len(s) - i, s[i])
            break

    k = ''.join(k)
    if(ispalindrome(k)):
        print(k)
    else:
        print("NA")

    #print(*k)

s = list(raw_input())
i = 0
ins = False
while (i < len(s)//2 ):
    n = len(s)
    if s[i] != s[n-1-i]:
        if ins or (i+1)*2==n: print "NA"; exit()
        ins = True
        if s[i] == s[n-2-i]:
            s.insert(i, s[n-1-i])
        else:
            s.insert(n-i, s[i])
    i += 1
if not ins:
    l = s[len(s)//2] if len(s) & 1 else 'y'
    s.insert(len(s)//2, l)
print ''.join(s)

s = raw_input()
n = len(s)
def f(s):
	n = len(s)
	for i in range(n):
		if s[i] != s[n-1-i]: return False
	return True

if f(s):
	s = s[0:n/2]+'y'+s[n/2:]
	print s
	exit()

flag = False
for a in range(n/2+1):
	if s[a] != s[n-1-a]:
		t = s[0:n-a]
		t += s[a]
		t += s[n-a:]
		if f(t):
			print t
			flag = True

if flag == False:
	print "NA"

s = input()
for i in range(26):
    for j in range(len(s)+1):
        s1 = s[:i]+chr(ord('a')+i)+s[i:]
        if s1[::-1] == s1:
            print (s1)
            exit(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
							break
					else:
						ind=i
						d+=1
				elif a[i+1]==a[-i-1]:
					if fr!=1:
						dead=True
						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 sys
from operator import itemgetter

from operator import mul    # or mul=lambda x,y:x*y
from fractions import Fraction

def main():
    pal = sys.stdin.readline().strip()
    n_pal = len(pal)
    inserted = False
    fucked_up = False

    for i_pal in range(n_pal):
        if pal[i_pal] != pal[n_pal - 1 - i_pal]:
        #     print
        #     print pal[i_pal], pal[n_pal - 1 - i_pal]
            if inserted:
                fucked_up = True
                break
            if pal[i_pal] == pal[n_pal - 2 - i_pal]:
                pal = pal[:i_pal] + pal[n_pal - 1 - i_pal] + pal[i_pal:]
            elif pal[i_pal + 1] == pal[n_pal - 1 - i_pal]:
                pal = pal[:n_pal - i_pal] + \
                    pal[i_pal] + pal[n_pal - i_pal:]

            else:
                fucked_up = True
                break
            # print pal
            # print

            inserted = True
            n_pal += 1
    if fucked_up:
        print "NA"
    else:
        if not(inserted):
            pal = pal[:int(n_pal/2)]+'a'+pal[int(n_pal/2):]
        print pal

main()

word = input().strip()

def testPalindrome(word):
	length = len(word)
	for x in range(int(length/2)):
		if (word[x] != word[length - 1 - x]):
			return False
	return True

def reverseString(word):
	return word[::-1]

def findIndex(word1, word2):
	length = len(word1)
	for i in range(length):
		if (word1[i] != word2[i]):
			return i
	return -1

def findDiffIndex(word):
	newString = ""
	if(len(word) % 2 == 0):
		first, second = word[:int(len(word)/2)], word[int(len(word)/2):][::-1]
		# print(first, second)
		a = findIndex(first, second)
		if (a == -1):
			newString = first + 'x' + second[::-1]
			print(newString)
		else:
			newString = first[:a] + second[a] + first[a:] + second[::-1]
			# print(newString)
			if(testPalindrome(newString)):
				print(newString)
			else:
				newString = first + second[a:][::-1] + first[a] + second[:a][::-1]
				# print(newString)
				if(testPalindrome(newString)):
					print(newString)
				else:
					print('NA')
	else:
		first, second = word[:int(len(word)/2)], word[int(len(word)/2)+1:][::-1]
		a = findIndex(first, second)
		# print(first, second, a)
		midChar = word[int(len(word)/2)]
		if (a == -1):
			newString = first + midChar + midChar + second[::-1]
			print(newString)
		else:
			newString = first[:a] + second[a] + first[a:] + midChar + second[::-1]
			# print(newString)
			if(testPalindrome(newString)):
				print(newString)
			else:
				newString = first + second[a:][::-1] + midChar + first[a] + second[:a][::-1]
				# print(newString)
				if(testPalindrome(newString)):
					print(newString)
				else:
					print('NA')

# print(word)
# print(len(word))

findDiffIndex(word)

# target Specialist

# Author : raj1307 - Raj Singh
# Date   : 15.07.19

from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def li(): return list(mi())

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()

#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import ceil,floor,log,sqrt,factorial,pow,pi
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading
#from itertools import permutations

abc='abcdefghijklmnopqrstuvwxyz'
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}
mod,MOD=1000000007,998244353
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
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)%p1
    return res

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

def isPrime(n) : # Check Prime Number or not
    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 read():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')

def main():

    #for _ in range(ii()):

    s=si()

    if True:
        a=list(s)
        b=list(s)
        f=1
        n=len(s)
        for i in range(len(s)):

            if s[i]!=s[n-i-1]:
                a.insert(i,s[n-i-1])
                b.insert(n-i,s[i])
                f=0
                break

        if f==1:
            print(s)
        else:
            if a==a[::-1]:
                print(''.join(a))
            elif b==b[::-1]:
                print(''.join(b))
            else:
                print('NA')

# region fastio

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

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    #read()
    main()
    #dmain()

# Comment Read()

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:];
        print(s1);
        s2=s1[::-1];
        if(s1==s2):
            print(s1);
            flag=1;
            break;
    if(flag==1):break;
if(flag==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

if __name__ == '__main__':
    main()

def ispal(st):
    for i in xrange(len(st)):
        if st[i] != st[-(i+1)]:
            return False
    return True

def oneDif(first,second):
    s1 = ''
    s2 = ''
    if len(first) > len(second):
        s1 = first
        s2 = second
    else:
        s1 = second
        s2 = first
    missing = ''
    pos = 0
    j = len(s2)-1
    for i in xrange(len(s1)):
        if s1[i] == s2[j]:
            j -= 1
        elif len(missing) == 0:
            missing = s1[i]
            pos = j+1
        else:
            return ''
    res = ''
    if pos == len(second):
        res = second + missing
    else:
        for i in xrange(len(second)):
            s = second[i]
            if i != pos:
                res += s
            else:
                res += missing
                res += s
    return first+res

s = raw_input()
if len(s) == 2:
    print s + s[0]
else:
    if len(s)%2 == 0:
        if ispal(s):
            print s[:len(s)/2]+'a'+s[len(s)/2:]
        else:
            done = False
            check = [len(s)/2,(len(s)/2)-1]
            for c in check:
                first = s[:c]
                second = s[c+1:]
                res = oneDif(first,second)
                if len(res) > 0:
                    print res[:len(res)/2]+s[c]+res[len(res)/2:]
                    done = True
                    break
            if not done:
                print 'NA'

    else:
        done = False
        if ispal(s):
            mid = len(s)/2
            print s[:mid]+s[mid]+s[mid:]
        else:
            check = [len(s)/2,(len(s)/2)+1]
            for c in check:
                first = s[:c]
                second = s[c:]
#                print c,first,second
                res = oneDif(first,second)
                if len(res) > 0:
                    print res
                    done = True
                    break
            if not done:
                print 'NA'

def isPalin(s) :
	rev=s[::-1]
	if s==rev:
		return True
	else :
		return False

s=raw_input()
n=len(s)

i=0
j=n-1

while i<j and s[i]==s[j] :
	i+=1
	j-=1
if i>=j :
	print s[:i]+s[i]+s[i:]
else :
	if isPalin(s[i+1:j+2]) :
		print s[:j+1]+s[i]+s[j+1:]
	elif isPalin(s[i:j]) :
		print s[:i]+s[j]+s[i:]
	else :
		print "NA"