Mr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly one lowercase English letter into s to make it a palindrome. A palindrome is a string that reads the same forward and backward. For example, "noon", "testset" and "a" are all palindromes, while "test" and "kitayuta" are not.You can choose any lowercase English letter, and insert it to any position of s, possibly to the beginning or the end of s. You have to insert a letter even if the given string is already a palindrome.If it is possible to insert one lowercase English letter into s so that the resulting string will be a palindrome, print the string after the insertion. Otherwise, print "NA" (without quotes, case-sensitive). In case there is more than one palindrome that can be obtained, you are allowed to print any of them.

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

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

NoteFor the first sample, insert 'r' to the end of "revive" to obtain a palindrome "reviver".For the second sample, there is more than one solution. For example, "eve" will also be accepted.For the third sample, it is not possible to turn "kitayuta" into a palindrome by just inserting one letter.

import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	static boolean isPalin(StringBuilder str) {
		String original = str.toString();
		String reverse = str.reverse().toString();
		//System.out.println(original + " == " + reverse + ": " + original.equals(reverse));
		return (original.equals(reverse));
	}

	public static void main(String args[]) throws FileNotFoundException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		boolean found = false;
		StringBuilder str = new StringBuilder(sc.nextLine());

		for (int i = 0; i <= str.length(); i++) {
			for (char c = 'a'; c <= 'z'; c++) {
				StringBuilder copy = new StringBuilder(str.toString());
				copy = copy.insert(i, c);
				if (isPalin(copy)) {
					found = true;
					pw.println(copy);
					break;
				}
			}
			if (found) break;
		}

		if (!found) pw.println("NA");
		sc.close();
		pw.close();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class A {

    public void solve(){

        String s = in.nextLine();
        int j = s.length() -1;
        boolean flag = false;

        int ind = -1;
        String c = "";
        boolean left = false;
        for(int i = 0; i<j; i++){
            if(s.charAt(i) != s.charAt(j)){
                if(flag){

                    other(s);
                    return;
                }
                else if( i <= j - 1 && s.charAt(i) == s.charAt(j-1)){
                    ind = i;
                    left = true;
                    c = Character.toString(s.charAt(j));
                    j--;
                    flag = true;
                }
                else if( i+1 <= j && s.charAt(i+1) == s.charAt(j)){
                    ind = j;
                    c = Character.toString(s.charAt(i));
                    i++;
                    flag = true;
                }

                else{
                    other(s);
                    out.flush();
                    return;
                }

            }
            j--;
        }

        if(flag){
            if(left){
                out.println(s.substring(0, ind ) + c + s.substring(ind));
            }
            else{
                out.println(s.substring(0, ind + 1) + c + s.substring(ind + 1));
            }
        }
        else if(s.length() % 2 == 0){
            out.println(s.substring(0,s.length() /2 ) + "a" + s.substring(s.length() /2 ));
        }
        else {
            out.println(s.substring(0, j+1) + s.charAt(j) + s.substring( j+1));
        }

    }

    public void other(String s){
        int j = s.length() -1;
        boolean flag = false;

        int ind = -1;
        String c = "";
        boolean left = false;
        for(int i = 0; i<j; i++){
            if(s.charAt(i) != s.charAt(j)){
                if(flag){
                    out.println("NA");
                    out.flush();
                    return;
                }
                else if( i+1 <= j && s.charAt(i+1) == s.charAt(j)){
                    ind = j;
                    c = Character.toString(s.charAt(i));
                    i++;
                    flag = true;
                }
                else if( i <= j - 1 && s.charAt(i) == s.charAt(j-1)){
                    ind = i;
                    left = true;
                    c = Character.toString(s.charAt(j));
                    j--;
                    flag = true;
                }
                else{
                    out.println("NA");
                    out.flush();
                    return;
                }

            }
            j--;
        }
        if(flag){
            if(left){
                out.println(s.substring(0, ind ) + c + s.substring(ind));
            }
            else{
                out.println(s.substring(0, ind + 1) + c + s.substring(ind + 1));
            }
        }
        else if(s.length() % 2 == 0){
            out.println(s.substring(0,s.length() /2 ) + "a" + s.substring(s.length() /2 ));
        }
        else {
            out.println(s.substring(0, j+1) + s.charAt(j) + s.substring( j+1));
        }
    }

    public static void main(String[] args){
        A m = new A();
        m.solve();
        m.out.flush();
        m.out.close();
    }

    InputStream inputStream;
    OutputStream outputStream;
    InputReader in;
    PrintWriter out;

    public A(){
        inputStream = System.in;
        outputStream = System.out;
        in = new InputReader(inputStream);
        out = new PrintWriter(outputStream);
    }

}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken();
    }
    public String nextLine(){
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        String s = "";
        while(tokenizer.hasMoreTokens()){
            s += tokenizer.nextToken();
            if(tokenizer.hasMoreTokens()){
                s+=" ";
            }
        }

        return s;

    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
    public double nextDouble(){
        return Double.parseDouble(next());
    }

    public long nextLong(){
        return Long.parseLong(next());
    }

    public float nextFloat(){
        return Float.parseFloat(next());
    }

}

import java.io.*;
import java.util.*;
import java.lang.*;
public class bf_str_505ACF {
    public static void main(String[] args){
        String ans="";
        Scanner sc=new Scanner(System.in);
        String str=sc.nextLine();
        int i=0,j=str.length()-1;
        bf_str_505ACF o=new bf_str_505ACF();
        while(i<=j){
            if(str.charAt(i)==str.charAt(j)){
                i++;
                j--;
                continue;
            }
            else{
                if(o.checkPal(str.substring(0,j+1) + str.charAt(i) + str.substring(j+1))){
                    System.out.println( str.substring(0,j+1) + str.charAt(i) + str.substring(j+1) );
                    return;
                }
                else if(o.checkPal(str.substring(0,i) + str.charAt(j) + str.substring(i))){
                    System.out.println( str.substring(0,i) + str.charAt(j) + str.substring(i) );
                    return;
                }
                i++;
                j--;
            }
        }
        if(o.checkPal(str.substring(0,str.length()/2 )+str.charAt(str.length()/2)+str.substring(str.length()/2) ) ){
            System.out.println( str.substring(0,str.length()/2 )+str.charAt(str.length()/2)+str.substring(str.length()/2) );
            return;
        }
        System.out.println("NA");

    }
    boolean checkPal(String str){

        StringBuilder rev=new StringBuilder();
        StringBuilder cp=new StringBuilder();
        rev.append(str);
        cp=rev;
        rev=rev.reverse();
        return str.equals(String.valueOf(rev));
    }
}

//package mainnn;
import java.util.*;
import java.lang.StringBuilder;
public class Mainnn {
    static int[][] G = new int[10001][3];
    static boolean[] vis = new boolean[100001];
    static String S;
    static int maxn=100001;
    static ArrayList <Integer> [] Av = new ArrayList[100001];
    static int[] cats;
    static int[] arr = new int[10001];
    static int N,M,cnt,cnt1,ind,ind1,ans,sum,summ,maxx,minn,mx=999999999,mn,x,y,z,x1,y2,z3,u,v;
    public static void main(String[] args) {
	Scanner scanf = new Scanner(System.in);
        S = scanf.next();
        StringBuilder Aa = new StringBuilder(S);
        for(int i=0; i<=S.length(); i++){
            for(char j=97; j<=122; j++){
                Aa.insert(i,(char)j);
                if(isPal(Aa)){
                    System.out.println(Aa);
                    close();
                }
                Aa.deleteCharAt(i);
            }
        }
        System.out.println("NA");
    }

    public static void close(){
        System.exit(0);
    }
    public static int MAX(int a, int b){
        return a>b? a : b ;
    }
    public static int ABS(int a){
        return a>0? a : -a;
    }
    public static int GCD(int a, int b){
        return b==0? a : GCD(b,b%a);
    }
    public static boolean isPal(StringBuilder SS){
        for(int i=0; i<SS.length()/2; i++){
            if(SS.charAt(i)!=SS.charAt(SS.length()-1-i)){
                return false;
            }
        }
        return true;
    }
    public static int funcX(String SS){
        int X=0;
        for(int i=0; i<SS.length(); i++){
            X=X*10+(SS.charAt(i)-'0');
        }
        return X;
    }
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Aaa {

	public static void main(String[] args) {
            Scanner input=new Scanner (System.in);
            String s=input.next();
            StringBuilder a=new StringBuilder(s);
             boolean c=false ;
     /*      if (isPalindrome(s)){
            if (s.length()%2==0){s=a.insert(s.length()/2, "a").toString();}
            else {s=a.insert(s.length()/2, "a").toString();}
            c=true;
            }

           */

            for (int i=0;i<=s.length()&&c==false;i++){
            for (int j=97;j<=(int)'z';j++){
            String x=new String(s);
            StringBuilder z=new StringBuilder(x);
            x=z.insert(i, (char)j).toString();
            if (isPalindrome(x)){s=x;c=true; break ;}

            }

            }
           if (c==false){s="NA";}

            System.out.print(s);

	}

public static boolean isPalindrome(String s ) {
int low = 0;

 int high = s.length()- 1;

 while (low < high) {
 if( s.charAt(low) != s.charAt(high))
return false;

 low++;
 high--;
 }

return true;
 }

}

/**
 * Created by Cole on 9/4/15.
 */

import java.util.Scanner;
import java.lang.StringBuilder;

public class mrKitayutasGift {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String currentWord = sc.next();
        createPalindrome(currentWord);

    }

    public static void createPalindrome(String originalString) {
        int length = originalString.length();
        StringBuilder word = new StringBuilder(originalString);
        StringBuilder newPalindrome = new StringBuilder(word.insert(length/2, word.charAt(length/2)).toString());
        if (isPalindrome(newPalindrome)) {
            System.out.println(newPalindrome);
            return;
        }

        for (int i = 0; i < length / 2; i++) {
            word = new StringBuilder(originalString);
            if (word.charAt(i) != word.charAt(length - i - 1)) {
                //System.out.println("charAt " + i + ": " + word.charAt(i) + " charAt " + (length - i - 1) + ": " + word.charAt(length - i - 1));
                newPalindrome = new StringBuilder(word.insert(i, word.charAt(length - i - 1)).toString());
                if (isPalindrome(newPalindrome)) {
                    System.out.println(newPalindrome);
                    return;
                }
                word = new StringBuilder(originalString);
                newPalindrome = new StringBuilder(word.insert(length - i, word.charAt(i)).toString());
                if (isPalindrome(newPalindrome)) {
                    System.out.println(newPalindrome);
                    return;
                }
            }
        }
        System.out.println("NA");
    }

    public static boolean isPalindrome (StringBuilder word) {
        int length = word.length();
        for (int i = 0; i < length / 2; i++) {
            if (word.charAt(i) != word.charAt(length - i - 1)) {
                return false;
            }
        }
        return true;
    }

}

import java.util.Scanner;
public class Kitayuta
{
     public static boolean pal(String s1){
         String s2 = new StringBuilder(s1).reverse().toString();

            if(s1.compareTo(s2)== 0){
                return true;
            }
            else{
                return false;
            }
    }

    public static void main(String args[])
    {
        Scanner input = new Scanner(System.in);
        String h = input.nextLine();

        String h1;
        boolean flag =false;
        char c;

        for (int i = h.length(); i >= args.length; i--)
        {
            for (int j = 0; j < 26; j++)
            {
                int x =97+j;
                c = (char) x;
                h1 = new StringBuilder(h).insert(i, c).toString();

                if(pal(h1)){
                    System.out.println(h1);
                    flag = true;
                    break;
                }
            }
            if(flag){break;}
        }
        if(!flag){System.out.println("NA");}
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        String flip = "";
        for (int i = 0 ; i < input.length() ; i++) {
            flip = flip + input.charAt(input.length() - 1 - i);
        }
        int mid = (input.length())/2;
        boolean check = true;
        boolean global = false;
        boolean before = false;
        for (int i = 0 ; i < mid || (i == mid && input.length()%2 != 0) ; i++) {
            if (input.charAt(i) != input.charAt(input.length() - i - 1)) {
                check = false;
                break;
            }
        }
        if (check) {
            global = true;
            for (int i = 0 ; i < input.length() ; i++) {
                if (i == mid)
                    System.out.print(input.charAt(i) + "" + input.charAt(i));
                else
                    System.out.print(input.charAt(i));
            }
        }
        else {
            for (int i = 0 ; i < mid  && !before ; i++) {
                if (input.charAt(i) != input.charAt(input.length() - i - 1)) {
                    boolean temp = true;
                    for (int j = i + 1 ; j < mid || (j == mid && input.length()%2 != 0); j++) {
                        if (input.charAt(j) != input.charAt(input.length() - j)) {
                            temp = false;
                            before = true;
                            break;
                        }
                    }
                    if (temp) {
                        global = true;
                        for(int j = 0 ; j < input.length() ; j++) {
                            if (j == input.length() - i - 1) {
                                System.out.print(input.charAt(j) + "" + input.charAt(i));
                            }
                            else
                                System.out.print(input.charAt(j));
                        }
                        break;
                    }
                }
            }
        }
        before = false;
        if (!global) {
            for (int i = 0 ; i < mid  && !before ; i++) {
                if (flip.charAt(i) != flip.charAt(flip.length() - i - 1)) {
                    boolean temp = true;
                    for (int j = i + 1 ; j < mid  || (j == mid && input.length()%2 != 0); j++) {
                        if (flip.charAt(j) != flip.charAt(input.length() - j)) {
                            temp = false;
                            before = true;
                            break;
                        }
                    }
                    if (temp) {
                        global = true;
                        for(int j = 0 ; j < input.length() ; j++) {
                            if (j == input.length() - i - 1) {
                                System.out.print(flip.charAt(j) + "" + flip.charAt(i));
                            }
                            else
                                System.out.print(flip.charAt(j));
                        }
                        break;
                    }
                }
            }
            if (!global) {
                boolean last = true;
                for (int i = 0 ; i < mid ; i++) {
                    if (input.charAt(i) != input.charAt(input.length() - i - 2)) {
                        last = false;
                        break;
                    }
                }
                if (last) {
                    System.out.print(input.charAt(input.length() - 1) + "" + input);
                }
                else
                    System.out.println("NA");
            }
        }
    }
}

import java.util.*;
import java.math.*;
import java.io.*;

public class MakePalindrom{

	public static void main(String[] args) throws Exception{
		Scanner pm = new Scanner(System.in);
		int[] hash = new int[26];
		String s = pm.next();
		int k = s.length();
		StringBuffer sb = new StringBuffer(s);
		if(k == 1){
			System.out.println(sb.append(sb));
			return;
		}
		for(int i=0;i<k;i++) {
			int po = (int)s.charAt(i) - 97;
			hash[po]++;
			//int -> Integer.parseInt(br.readLine());
			/*int[] -> String str = br.readLine();
					   String[] astr = str.split(" ");
					   for(int i=0;i<n;i++)
				   	   arr[i] = Integer.parseInt(astr[i]);*/

		} //end of test case
		//int max = Arrays.stream(hash).max().orElse(0);
		int cnt = 0;
		ArrayList<Character> pos = new ArrayList<>();
		ArrayList<Character> pl = new ArrayList<>();
		for(int i=0;i<k;i++)
				pl.add(s.charAt(i));
		ArrayList<Character> pl2 = new ArrayList<>();
		for(int i=0;i<k;i++)
				pl2.add(s.charAt(i));
		int a = 0;
		int nom = 0;
		int flag = 0;
		int ins = 0;
		int n = pl.size();
		int pt1 = 0;
		int pt2 = n-1;
		while(true){
			//System.out.println(pl.get(pt1)+" "+pl.get(pt2));
			if(pl.get(pt1) == pl.get(pt2) ){
				pt1++;
				pt2--;
				//continue;
			}
			else if(nom == 0) {

				nom = 1;
				pl.add(pt2+1,pl.get(pt1));
				ins = 1;
				pt1++;
			}
			else if(nom == 1) {
				flag = 1;
				break;
			}
			//a++;
			if(pt1 == pt2 - 1 || pt1 >= pt2)
				break;
			//System.out.println(pl);
		}
		pt1 = 0;
		pt2 = n-1;
		nom = 0;
		int flag2=0;
		int check2 = 0;
		int ins2 = 0;
		while(true){
			//System.out.println(pl.get(pt1)+" "+pl.get(pt2));
			if(pl2.get(pt1) == pl2.get(pt2) ){
				pt1++;
				pt2--;
				//continue;
			}
			else if(nom == 0) {

				nom = 1;
				pl2.add(pt1,pl2.get(pt2));
				ins2 = 1;
				pt1++;
			}
			else if(nom == 1) {
				flag2 = 1;
				break;
			}
			//a++;
			if(pt1 == pt2 - 1 || pt1 >= pt2)
				break;
			//System.out.println(pl);
		}
		if(ins == 0 && n % 2 == 0){
			pl.add(n/2,'a');
		}
		if(ins2 == 0 && n % 2 == 0){
			pl2.add(n/2,'a');
		}
		if(ins == 0 && n % 2 == 1){
			pl.add(n/2,pl.get(n/2));
		}
		if(ins2 == 0 && n % 2 == 1){
			pl2.add(n/2,pl2.get(n/2));
		}
		StringBuilder b1 = new StringBuilder();
		pl.forEach(b1::append);
		StringBuilder b2 = new StringBuilder();
		pl2.forEach(b2::append);
		boolean c1 = isPal(b1.toString());
		boolean c2 = isPal(b2.toString());

		//System.out.println(flag);
		//System.out.println(pl2);

		if(!c1 && !c2)
			System.out.println("NA");
		else if(c1)
			System.out.println(b1.toString());
		else
			System.out.println(b2.toString());
		// else if(ins == 0 && n % 2 == 1)
		// 	flag = 1;
		// if(flag == 1)
		// 	System.out.println("NA");
		// else{

  //  			System.out.println(b);
		// }

	} //end of main()

	static boolean isPal(String str)
    {

        // Pointers pointing to the beginning
        // and the end of the string
        int i = 0, j = str.length() - 1;

        // While there are characters toc compare
        while (i < j) {

            // If there is a mismatch
            if (str.charAt(i) != str.charAt(j))
                return false;

            // Increment first pointer and
            // decrement the other
            i++;
            j--;
        }

        // Given string is a palindrome
        return true;
    }
} //end of class

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        BufferedReader bufferedReader = new BufferedReader(
                new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();
        String s = bufferedReader.readLine();
        builder.append(s);
        boolean char_inserted = false;
        int len = s.length();
        char tmp = 0;
        String result = "";
        for (int i = 0; i < len / 2; i++) {
            if ((tmp = builder.charAt(i)) == builder.charAt(len - i - 1)) {
                continue;
            } else {
                if ((tmp = builder.charAt(i)) != builder.charAt(len - i - 1)
                        && !char_inserted) {
                    builder.insert(len - i, tmp);
                    len += 1;
                    char_inserted = true;
                } else {
                    result = "NA";
                    break;
                }
            }
        }

        if (result.equals("NA")) {
            char_inserted = false;
            builder = new StringBuilder();
            builder.append(s);
            len = s.length();
            result = "";
            for (int i = 0; i < len / 2; i++) {
                tmp = builder.charAt(len - i - 1);
                if (builder.charAt(i) == (builder.charAt(len - i - 1))) {
                    continue;
                } else {
                    if ((builder.charAt(i)) != builder.charAt(len - i - 1)
                            && !char_inserted) {
                        builder.insert(i, tmp);
                        len += 1;
                        char_inserted = true;
                    } else {
                        result = "NA";
                        break;
                    }
                }
            }
        }
        if (result.equals("NA")) {
            System.out.println(result);
        } else {
            if (s.length() < builder.length()) {
                System.out.println(builder.toString());
            } else {
                builder.insert(len / 2, builder.charAt(len / 2));
                System.out.println(builder.toString());
            }
        }

    }

}

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static boolean isPalin(String s) {

        for(int i = 0, j = s.length()-1; i < s.length()/2; i++,--j) {
            if(s.charAt(i) != s.charAt(j))
                return false;
        }
        return true;
    }
    public static void main(String[] args) throws Exception {
        char[] a = {'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'};
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = in.readLine();
        boolean flag = true;
        for(int i = 0; i <= s.length(); i++) {
            for(int j = 0; j < a.length; j++) {
                String tmp = s.substring(0,i) + a[j] + s.substring(i);
                if(isPalin(tmp)) {
                    System.out.println(tmp);
                    j = a.length;
                    i = s.length();
                    flag = false;
                }
            }
        }
        if(flag)
            System.out.println("NA");
    }

}

import java.util.Scanner;

public class Main {
	private static Scanner s;

	public static void main(String[] args) {
		s = new Scanner(System.in);
		String First=s.next(), Edit="" ;
		int i,t;
		boolean v = true;
		char[] alphabet = "abcdefghijklmnopqrstuvwxyz".toCharArray();
		for (i=0;(i<=First.length())&&v;i++)
		{
			for (t=0;(t<26)&&v;t++)
			{
				Edit=First.substring(0,i)+(alphabet[t])+First.substring(i,First.length());
				if(Edit.equals(new StringBuilder(Edit).reverse().toString()))
				{
					System.out.println(Edit);
					v=false;
					return;
				}
			}

		}
		if (v)
		{
			System.out.println("NA");
		}

	}

}

import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Jitendra Kushwaha
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
    public void solve(int testNumber, FastScanner in, PrintWriter out) {
        String str = in.nextString();
        int n = str.length();

        int diff = 0;
        for (int i = 0; i < n/2; ++i) {
            if(str.charAt(i) == str.charAt(n-1-i))
                continue;
            else {
                if (isPal(str, i, n - i - 2)) {
                    out.println(str.substring(0, i) + str.substring(n - i - 1, n - i) + str.substring(i));
                    return;
                } else if (isPal(str, i + 1, n - i - 1)) {
                    out.println(str.substring(0, n - i) + str.substring(i, i + 1) + str.substring(n - i));
                    return;
                } else {
                    diff = 1;
                    break;
                }
            }
        }
        if(diff == 0 && (n % 2 == 0)) {
            out.println(str.substring(0, n/2) + "y" + str.substring(n/2));
        }
        else if(diff == 0 && (n % 2 == 1)) {
            out.println(str.substring(0, n/2) + str.substring(n/2, n/2+1) + str.substring(n/2));
        }
        else
            out.println("NA");
    }

    private boolean isPal(String str, int i, int j) {
        for (; i < j; ++i, --j) {
            if(str.charAt(i) != str.charAt(j))
                return false;
        }
        return true;
    }
}

class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    public FastScanner(InputStream stream) {
        br = new BufferedReader(new InputStreamReader(stream));
    }

    public String nextString() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return st.nextToken();
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *
 * @author giovanny
 */
public class A86 {

    A86(String cadena) {
        String resu=Resuelve(cadena,0);
        if(resu.equals("NA"))
            resu=Resuelve(cadena,1);
        System.out.println(resu);
    }

    public String Resuelve(String cadena, int op) {
        int izq = 0;
        int der = cadena.length() - 1;
        boolean ban = false;
        while (izq < der) {
            if (cadena.charAt(izq) == cadena.charAt(der)) {
                izq++;
                der--;
            } else {
                if (!ban) {
                    if(op==0){
                        if (cadena.charAt(izq + 1) == cadena.charAt(der)) {
                            cadena = cadena.substring(0, der + 1) + cadena.charAt(izq) + cadena.substring(der + 1);
                            izq++;
                        } else if (cadena.charAt(izq) == cadena.charAt(der - 1)) {
                            cadena = cadena.substring(0, izq) + cadena.charAt(der) + cadena.substring(izq);
                            der++;
                        }
                        ban = true;
                    }
                    else{
                        if (cadena.charAt(izq) == cadena.charAt(der - 1)) {
                            cadena = cadena.substring(0, izq) + cadena.charAt(der) + cadena.substring(izq);
                            der++;
                        }else if (cadena.charAt(izq + 1) == cadena.charAt(der)) {
                            cadena = cadena.substring(0, der + 1) + cadena.charAt(izq) + cadena.substring(der + 1);
                            izq++;
                        }
                        ban=true;
                    }
                } else {
                    return "NA";
                }
            }
        }
        if (!ban) {
            cadena = cadena.substring(0, izq) + cadena.charAt(der) + cadena.substring(izq);
        }
        return cadena;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String giro = in.readLine();
        new A86(giro);
    }
}

public class Main {
    public static void main(String[] args){

        java.util.Scanner input = new java.util.Scanner(System.in);
        String s = input.next();
        int l = s.length();

        if(p(s)){
            System.out.println(s.substring(0, l/2) + s.charAt(l/2) + s.substring(l/2));
            System.exit(0);
        }

        for(int i = 0, j = l-1; i < l/2; i++, j--){
            if(s.charAt(i)!= s.charAt(j)){
                String s1 = s.substring(0, j+1) + s.charAt(i) + s.substring(j+1);
                String s2 = s.substring(0, i) + s.charAt(j) + s.substring(i);
                if(p(s1)){
                    System.out.println(s1);
                    System.exit(0);
                }
                if(p(s2)){
                    System.out.println(s2);
                    System.exit(0);
                }
                break;
            }
        }

        System.out.println("NA");
    }

    public static boolean p(String s){
        for(int i = 0, j = s.length() - 1; i < s.length(); i++, j--)
            if(s.charAt(i)!= s.charAt(j))
                return false;

        return true;
    }
}

// package Div2;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;

public class Sketch {
	private static boolean test(String str, int n){
		int offset = 0;
		int cur = 0;
		while(cur <= str.length()/2){
			if(cur == n){
				offset = 1;
				cur++;
				continue;
			}
			if(str.length()-1-cur == n){
				offset = -1;
				cur++;
				continue;
			}
			if(str.charAt(cur) != str.charAt(str.length()-1+offset-cur)){
				return false;
			}
			cur++;
		}
		return true;
	}

	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		String str = input.next();
		input.close();

		boolean flag = true;
		for(int i=0; i<str.length()/2; i++){
			if(str.charAt(i) != str.charAt(str.length()-1-i)){
				flag = false;
				break;
			}
		}

		StringBuffer ret = new StringBuffer();
		if(flag){
			for(int i=0; i<str.length()/2; i++){
				ret.append(str.charAt(i));
			}
			ret.append(str.charAt(str.length()/2));
			for(int i=str.length()/2; i<str.length(); i++)
				ret.append(str.charAt(i));
			System.out.println(ret.toString());
			return;
		}

		int mark = -1;
		for(int i=0; i<str.length(); i++){
			if(test(str, i)){
				mark = i;
				break;
			}
		}

		if(mark == -1){
			System.out.println("NA");
			return;
		}

		if(mark < str.length()/2){
			for(int i=0; i<str.length()-mark; i++)
				ret.append(str.charAt(i));
			ret.append(str.charAt(mark));
			for(int i=str.length()-mark; i<str.length(); i++)
				ret.append(str.charAt(i));
		}
		else {
			for(int i=0; i<str.length()-mark-1; i++){
				ret.append(str.charAt(i));
			}
			ret.append(str.charAt(mark));
			for(int i=str.length()-mark-1; i<str.length(); i++)
				ret.append(str.charAt(i));
		}

		System.out.println(ret.toString());
	}
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

// http://codeforces.com/problemset/problem/505/A

public class Kitayuta {

	public static void main(String[] arg) {
		Scanner input = new Scanner(System.in);
		String word = input.nextLine();
		System.out.println(Kitayuta(word));
	}

	/*
	 * checks to see if something is a palindrome
	 */
	public static boolean isPalindrome(String input) {
		int length = input.length();
		int limit = length / 2;
		int endCharStart = length - 1;
		for (int i = 0; i < limit; i++) {
			char firstChar = input.charAt(i);
			char secondChar = input.charAt(endCharStart - i);
			if (firstChar != secondChar) {
				return false;
			}

		}
		return true;
	}

	//does the kitayuta gift
	public static String Kitayuta(String input) {
		int length = input.length();
		if (isPalindrome(input)) {
			return alreadyPalindrome(input);
		}
		else {
			return notPalindrome(input);
		}
	}

	/*
	 * if it's already a palindrome, you either insert a random letter, or just insert the middle letter into the middle letter again
	 */
	public static String alreadyPalindrome(String input) {
		int length = input.length();
		int halfPos = length / 2;
		/*
		 * if it's even you can simply just put any char into the middle, it'll stay a palindrome
		 */
		if (length % 2 == 0) {
			String firstHalf = input.substring(0, halfPos);
			String secondHalf = input.substring(halfPos);
			return firstHalf + "a" + secondHalf;
		}
		/*
		 * if it's odd than you need to take the  "middle" letter ex eye take y , and put it after the first "middle" letter ex eyye
		 */
		else {
			char middleChar = input.charAt(halfPos);
			String firstHalf = input.substring(0, halfPos + 1);
			String secondHalf = input.substring(halfPos + 1);
			return firstHalf + middleChar + secondHalf;
		}
	}

	/*
	 * if it's not a palindrome just bruteforce, note you could just bruteforce it all.
	 */
	public static String notPalindrome(String input) {
		boolean[] existingChars = getChars(input);
		ArrayList<Character> charArrs = charArrays(existingChars);
		int lengthOfArrs = charArrs.size();
		for (int pos = 0; pos < input.length() + 1; pos++) {
			for (int charPos = 0; charPos < lengthOfArrs; charPos++) {
				char currentChar = charArrs.get(charPos);
				String updated = insertChar(input, pos, currentChar);
				if (isPalindrome(updated)) {
					return updated;
				}
			}
		}
		return "NA";
	}

	/*
	 * inserts a character given at a position given into the input
	 */
	public static String insertChar(String input, int pos, char character) {
		int length = input.length();
		String firstHalf = input.substring(0, pos);
		String secondHalf = input.substring(pos);
		return firstHalf + character + secondHalf;
	}
	/*
	 * creates a boolean array, sets characters that exit to true.
	 */
	public static boolean[] getChars(String input) {
		boolean[] chars = new boolean[26];
		for (int i = 0; i < input.length(); i++) {
			char currentChar = input.charAt(i);
			int posInArray = currentChar - 'a';
			chars[posInArray] = true;
		}
		return chars;
	}

	/*
	 * Goes through the boolean of chars, then adds the chars to an ArrayList of chars.
	 */
	public static ArrayList<Character> charArrays(boolean[] chars) {
		ArrayList<Character> charArr = new ArrayList<Character>();
		for (int i = 0; i < chars.length; i++) {
			if (chars[i] == true) {
				char convertedChar = (char) ('a' + i);
				charArr.add(convertedChar);
			}
		}
		return charArr;

	}
}

import java.util.Scanner;
import static java.lang.System.out;

public class KitayutaGift {

    private void answer() {
        Scanner scan = new Scanner(System.in);
        String word = scan.next();
        String abc = "abcdefghijklmnopqrstuvwxyz";
        for (int i = 0; i <= word.length(); i++) {
            for (int j = 0; j < 26; j++) {
                String palin = word.substring(0, i) + Character.toString(abc.charAt(j))
                        + word.substring(i);
//                out.println(palin);
                if (isPalin(palin)) {
                    out.println(palin);
                    return;
                }
            }
        }
        out.println("NA");
    }

    private boolean isPalin(String s) {
        for (int i = 0; i < s.length()/2; i++) {
            if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
                return false;
            }
        }
        return true;
    }

    public static void main (String[] args) {
        KitayutaGift a = new KitayutaGift();
        a.answer();
    }
}

//package code;

import java.util.Scanner;

public class dab {

	public static boolean check(String s){

		StringBuilder temp=new StringBuilder(s).reverse();

		return temp.toString().equals(s);
	}

	public static void main(String args[]){

		Scanner in=new Scanner (System.in);
		String S=in.nextLine();
		String temp="";

		if(S.length()==1){
			System.out.println(S+S);
			return;
		}
		else if (check(S)&&S.length()%2==0){
			S=S.substring(0, S.length()/2)+"a"+S.substring(S.length()/2);
			System.out.println(S);
			return;
		}
		else
		{
			for(int i=97;i<123;i++){
				temp=(char)i+S;
				if(check(temp)){
					System.out.println(temp);
					return ;
				}
			}
			for(int a=1;a<S.length()+1;a++){
				for(int i=97;i<123;i++){
					temp=S.substring(0,a)+(char)i+S.substring(a);
					if(check(temp)){
						System.out.println(temp);
						return ;
					}
				}
			}

		}
		System.out.println("NA");

	}
}

import java.util.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		String s = new String();
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()){
			s = cin.next();
			int len = s.length();
			int res = -1;
			for(int i = 0 ; i < len ; i ++){
				int l = 0 ,r = len - 1;
				int tres = 1;
				while(l <= r){
					if(l == i){
						l ++;
						continue;
					}
					if(r == i){
						r --;
						continue;
					}
					if(s.charAt(l) != s.charAt(r)) tres = 0;
					l ++;r --;
				}
				if(tres == 1) res = i;
				if(res != -1) break;
			}
			if(res == -1) System.out.println("NA");
			else{
				if(res < len / 2){
					for(int i = 0 ; i < (len + 1) / 2 ; i ++)
						System.out.print(s.charAt(i));
					if(len % 2 == 0) System.out.print(s.charAt(len / 2));
					for(int i = (len + 1) / 2 - 1 ; i >= 0 ; i --)
						System.out.print(s.charAt(i));
					System.out.println();
				}
				else{
					for(int i = 0 ; i < (len + 1) / 2 ; i ++)
						System.out.print(s.charAt(len - 1 - i));
					if(len % 2 == 0) System.out.print(s.charAt(len / 2 - 1));
					for(int i = (len + 1) / 2 - 1 ; i >= 0 ; i --)
						System.out.print(s.charAt(len - 1 - i));
					System.out.println();
				}
			}
		}
	}
}

import java.util.*;
import java.math.*;
import java.io.*;
import java.text.*;
import java.awt.Point;

import static java.util.Arrays.*;
import static java.lang.Integer.*;
import static java.lang.Double.*;
import static java.lang.Long.*;
import static java.lang.Short.*;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
import static java.util.Collections.*;

public class A {

	private Scanner in;
	private StringTokenizer st;
	private PrintWriter out;

	private DecimalFormat fmt = new DecimalFormat("0.0000000000");

	public void solve() throws Exception {
		String str = in.next().trim();
		int n = str.length();

		for (int i=0; i <= n; i++) {
			for (int j=0; j<26; j++) {
				char insert = (char) ('a' + j);
				String tmp = str;

				if (i == -1) {
					tmp = insert + tmp;
				} else if (i == n) {
					tmp += insert;
				} else {
					tmp = str.substring(0, i) + insert + str.substring(i, n);
				}

				if (check(tmp)) {
					out.println(tmp);
					return;
				}
			}
		}

		out.println("NA");
	}

	private boolean check(String str) {
		for (int i=0; i<str.length(); i++) {
			if (str.charAt(i) != str.charAt(str.length() - i - 1)) {
				return false;
			}
		}
		return true;
	}

	public A() {
		this.in = new Scanner(System.in);
		this.out = new PrintWriter(System.out);
	}

	public void end() {
		try {
			this.out.flush();
			this.out.close();
			this.in.close();
		} catch (Exception e){
			//do nothing then :)
		}
	}

	public static void main(String[] args) throws Exception {
		A solver = new A();
		solver.solve();
		solver.end();
	}
}

import java.util.*;
public class E {
	public static boolean isPalin(String str){
		int n= str.length();
		for(int i=0;i<n/2;i++){
			if(str.charAt(i)!=str.charAt(str.length()-i-1))
				return false;
		}
		return true;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		for(int i=0;i<=s.length();i++){
			for(int y=0;y<26;y++){
				String str = s.substring(0,i)+ (char) (y+'a') + s.substring(i);
				if(isPalin(str)){
					System.out.println(str);
					return;
					}

			}
		}
		System.out.println("NA");

	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.nio.file.attribute.AclEntry.Builder;
import java.util.Scanner;

public class P505_A {

	private static StreamTokenizer inputReader = new StreamTokenizer(
			new BufferedReader(new InputStreamReader(System.in)));

	private static Scanner scaner = new Scanner(System.in);

	static java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));

	public static int nextInt() {
		int a = -1;
		try {
			inputReader.nextToken();
			a = (int) inputReader.nval;
		} catch (Exception e) {
		}
		return a;
	}

	public static void main(String[] args) throws IOException {
		String line = reader.readLine();

		StringBuilder builder = null;
		for (int i = 0; i < line.length(); i++) {
			String string = line.substring(0, i) + line.substring(i + 1);

			if (isPalindrome(string)) {
				builder = new StringBuilder(line);

//				System.out.println(string);
				if (i <= line.length() / 2) {
					builder.insert(line.length() - i, line.charAt(i));
				}else {
					builder.insert(line.length() - i - 1, line.charAt(i));
				}
				System.out.println(builder);
				return;
			}
		}

		System.out.println("NA");
	}

	private static boolean isPalindrome(String line) {
		for (int i = 0; i < line.length() / 2; i++) {
			if (line.charAt(i) != line.charAt(line.length() - i - 1)) {
				return false;
			}
		}

		return true;
	}

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Solution_505A {
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        char[] chars = reader.readLine().toCharArray();

        ArrayList<char[]> varChars = new ArrayList<char[]>();
        for (int i = 0; i <= chars.length; i++) {
            char[] var = new char[chars.length + 1];
            var[chars.length - i] = (i <= chars.length / 2) ? chars[i] : chars[i - 1];

            for (int j = 0; j < chars.length - i; j++)
                var[j] = chars[j];
            for (int j = chars.length - i; j < chars.length; j++)
                var[j + 1] = chars[j];

            varChars.add(var);
        }

        for(char[] test : varChars) {
            Boolean find = false;

            for (int i = 0; i < test.length / 2; i++) {
                find = true;
                if(test[i] == test[test.length - 1 - i])
                    continue;
                else {
                    find = false;
                    break;
                }
            }

            if(find) {
                for(char ch : test)
                    System.out.print(ch);
                System.out.println();
                System.exit(0);
            }
        }

        System.out.println("NA");

//        int sz = chars.length;
//        char[] out = new char[sz + 1];
//        int ins = 0;
//
//        out[sz / 2] = chars[sz / 2]; // set middle character
//
//        for (int i = 0; i < out.length / 2; i++) {
//            out[i] = chars[i];
//            out[sz - i] = chars[i];
//            if(chars[i] != chars[sz - i - 1 + ins])
//                ins++;
//
//            // ignore previous and start new cycles
//            if (ins > 1) {
//                ins = 0;
//                for (i = out.length - 1; i >= out.length / 2; i--) {
//                    out[i] = chars[i - 1];
//                    out[sz - i] = chars[i - 1];
//                    if(chars[i - 1] != chars[sz - i - ins])
//                        ins++;
//                    if (ins > 1)
//                        break; // not found
//                }
//                break; // not found
//            }
//        }
//
//        if(ins <= 1) { // check if found
//            for (char ch : out)
//                System.out.print("" + ch);
//            System.out.println();
//
//        } else
//            System.out.println("NA");
    }
}

import java.util.*;
public class Main
{
	public static void main(String[]args)
	{
		Scanner input=new Scanner (System.in);
		while(input.hasNext())
		{
			String s=input.nextLine(),a="";
			int x=0,y=0,n=s.length();
			boolean b=true;
			for(x=0;x<s.length()/2;x++)
				if(s.charAt(x)!=s.charAt(s.length()-x-1))
					{
						b=false;
						y=x;
						break;
					}
			if(b)
				System.out.println(s.substring(0,(int)Math.ceil(s.length()/2.0))+s.charAt(s.length()/2)+s.substring((int)Math.ceil(s.length()/2.0),s.length()));
			else
			{
				b=true;
				a=s.substring(0,y)+s.charAt(n-y-1)+s.substring(y,n);
				for(x=0;x<a.length()/2;x++)
					if(a.charAt(x)!=a.charAt(a.length()-x-1))
					{
						b=false;
						break;
					}
				if(!b)
				{
					b=true;
					a=s.substring(0,n-y)+s.charAt(y)+s.substring(n-y,n);
					for(x=0;x<a.length()/2;x++)
						if(a.charAt(x)!=a.charAt(a.length()-x-1))
						{
							b=false;
							break;
						}
				}
				if(b)
					System.out.println(a);
			}
			if(!b)
				System.out.println("NA");
		}
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public String findPalindrome(String argument) {
        StringBuilder arg = new StringBuilder(argument);
        StringBuilder value = new StringBuilder(argument);
        arg = arg.reverse();
        int length = arg.length();
        boolean flag = false, found = true;
        for (int i = 0; i < length; i++) {
            if (value.charAt(i) == arg.charAt(i)) {
                continue;
            }
            if (!flag) {
                arg.insert(i, value.charAt(i));
                value.insert(length - i, value.charAt(i));
                if (arg.toString().equals(value.toString())) {
                    flag = true;
                    break;
                }
                arg.delete(i, i + 1);
                value.delete(length - i, length - i + 1);
                value.insert(i, arg.charAt(i));
                arg.insert(length - i, arg.charAt(i));
                if (arg.toString().equals(value.toString())){
                    flag = true;
                    break;
                }
                found = false;
                break;
            }
        }
        if (!flag) {
            if (length == 1) {
                value.insert(0, value.charAt(0));
            } else if (length % 2 == 0)
                value.insert(length / 2, 'a');
            else {
                value.insert(length / 2 + 1, value.charAt(length / 2));
            }
        }
        if (found)
            return value.toString();
        else
            return "NA";
    }
    public static void main(String[] args) throws IOException{
        Main main = new Main();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String argument;
        argument = br.readLine();
        br.close();
        String palindrome = main.findPalindrome(argument);
        System.out.println(palindrome);
    }
}

import java.util.*;
import java.io.*;

public class A {

  static int N;
  static int A[];

  static String palindrome(String s) {
    if (isPal(s)) {
      if (s.length()%2 == 0) {
        return evenPal(s);
       } else {
         return oddPal(s);
       }
    }
    // Not a palindrome.
    for (int i=0; i<=s.length(); i++) {
      String result = insert(s, i);
      if (result != null) {
        return result;
      }
    }
    return "NA";
  }

  static String insert(String s, int index) {
    for(char alphabet = 'a'; alphabet <= 'z';alphabet++) {
      String result = "not";
      if (index == 0) {
        result = alphabet + s;
      } else if (index == s.length()) {
        result = s + alphabet;
      } else {
        result = s.substring(0, index) + alphabet + s.substring(index, s.length());
      }
      if (isPal(result)) return result;
    }
    return null;
  }

  static String evenPal(String s) {
    int index = s.length()/2;
    String result = "";
    for (int i=0; i<index; i++) {
      result += s.charAt(i);
    }
    String reverse = rev(result);
    return result + "a" + reverse;
  }

  static String oddPal(String s) {
    int index = s.length()/2;
    String result = "";
    for (int i=0; i<=index; i++) {
      result += s.charAt(i);
    }
    String reverse = rev(result);
    return result + reverse;
  }

  static String rev(String s) {
    String result = "";
    for (int i=s.length()-1; i>=0; i--) {
      result += s.charAt(i);
    }
    return result;
  }

  static boolean isPal(String s) {
    String reverse = rev(s);
    return (reverse.equals(s));
  }
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String s = br.readLine();
    System.out.println(palindrome(s));
  }
}

import java.util.Scanner;
//import java.util.StringBuffer;
public class main
{
    public static void main(String args[])
    {
        Scanner input = new Scanner(System.in);
        String x = input.nextLine();
        int n = x.length();
        char arr[] = new char[n];
        //System.out.println(isPallindrome(arr));
        for(int i=0;i<n;i++)
        {
            arr[i] = x.charAt(i);
        }
        if(isPallindrome(x))
        {
            if(n%2 != 0)
            {
                System.out.println(x.substring(0,n/2+1)+Character.toString(arr[n/2])+x.substring(n/2+1,n));
            }
            else
            {
                System.out.println(x.substring(0,n/2)+"y"+x.substring(n/2,n));
            }
            System.exit(0);
        }
        int i=0;
        int j = n-1;
        int y = 0;
        String t = "";
        String m = "";
        while(i <= j)
        {
            if(arr[i] != arr[j])
            {
                String l = x.substring(i,j+1);
                //System.out.println("t: "+t);
                //System.out.println("l: "+l);
                l += Character.toString(arr[i]);
                //System.out.println("l: "+l);
                if(isPallindrome(l))
                {
                    y = 1;
                    System.out.println(t+l+m);
                    System.exit(0);
                }
                String f = x.substring(i,j+1);
                f = Character.toString(arr[j]) + f;
                if(isPallindrome(f))
                {
                    y = 1;
                    System.out.println(t+f+m);
                    System.exit(0);
                }
                break;
//              System.exit(0);
            }
            t += Character.toString(arr[i]);
            m = Character.toString(arr[j])+m;
            i++;
            j--;
        }
        if(y == 0)
        {
            System.out.println("NA");
        }
    }
    public static boolean isPallindrome(String z)
    {
        int n = z.length();
        char arr[] = new char[n];
        for(int i=0;i<n;i++)
                {
                        arr[i] = z.charAt(i);
                }
        //System.out.println(arr[0]);
        int i=0;
        int j = n-1;
        while(i<=j)
        {
            if(arr[i] != arr[j])
            {
//              System.out.println("Hello");
                return false;
            }
            i++;
            j--;
        }
        return true;
    }
}

//package mainnn;
import java.util.*;
import java.lang.StringBuilder;
public class Mainnn {
    static int[][] G = new int[10001][3];
    static boolean[] vis = new boolean[100001];
    static String S;
    static int maxn=100001;
    static ArrayList <Integer> [] Av = new ArrayList[100001];
    static int[] cats;
    static int[] arr = new int[10001];
    static int N,M,cnt,cnt1,ind,ind1,ans,sum,summ,maxx,minn,mx=999999999,mn,x,y,z,x1,y2,z3,u,v;
    public static void main(String[] args) {
	Scanner scanf = new Scanner(System.in);
            S = scanf.next();
        StringBuilder Aa = new StringBuilder(S);
        for(int i=0; i<=S.length(); i++){
            for(char j='a'; j<='z'; j++){
                Aa.insert(i,j);
                if(isPal(Aa)){
                    System.out.println(Aa);
                    close();
                }
                Aa.deleteCharAt(i);
            }
        }
        System.out.println("NA");
    }

    public static void close(){
        System.exit(0);
    }
    public static int MAX(int a, int b){
        return a>b? a : b ;
    }
    public static int ABS(int a){
        return a>0? a : -a;
    }
    public static int GCD(int a, int b){
        return b==0? a : GCD(b,b%a);
    }
    public static boolean isPal(StringBuilder SS){
        for(int i=0; i<SS.length()/2; i++){
            if(SS.charAt(i)!=SS.charAt(SS.length()-1-i)){
                return false;
            }
        }
        return true;
    }
    public static int funcX(String SS){
        int X=0;
        for(int i=0; i<SS.length(); i++){
            X=X*10+(SS.charAt(i)-'0');
        }
        return X;
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class MrKitayutaGift {

    static boolean palindrome(String w)
    {
        for (int i =0 ; i<w.length()/2;i++)
            if(w.charAt(i) != w.charAt(w.length()-i-1))
                return false ;
        return true ;
    }

    public static void main(String[] args)  throws Exception{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String word = in.readLine() ;
        char c ,c2 ;
        String word2 =word,end2 ;
        int l = word.length() ;
        int nb=0 ;
        String end ;
        for(int i = 0 ; i< (l/2) && nb < 1 ; i++ )
        {
            c = word.charAt(i) ;
            c2  = word.charAt( l - i -1 ) ;
            if(c != c2 )
            {
                end ="" ;
                end2 ="" ;
                if(i != 0)
                {
                    end= word.substring(l - i) ;
                    end2 = word.substring(0, i ) ;
                }
                word = word.substring(0,l - i) + c +end ;
                word2 = end2 + c2 + word2.substring(i);
                nb++ ;
            }
        }
        if(nb==0)
        {
            word = word.substring(0,(l/2)+1) + word.substring(l/2) ;
            System.out.println(word) ;
        }
        else if(palindrome(word))
        {
            System.out.println(word);
        }
        else if(palindrome(word2))
        {
            System.out.println(word2);
        }
         else
        {
            System.out.println("NA");
        }

    }

}

import java.util.Scanner;
public class Helloworld
{
     public static void main(String[] args)
  {
      Scanner in = new Scanner(System.in);
      String word = in.next();
      System.out.println(solve(word));
  }

  public static String reverse(String w){
    String temp = "";
    for(int i = w.length() -1 ; i>=0;i--)temp+=w.charAt(i);
    return temp;
  }
  public static String solve(String w){

      String temp = "abcdefghijklmnopqrstuvwxyz";
      for(int i = 0 ; i < temp.length();i++)
      {
          for(int j = 0 ; j <= w.length();j++){
            String tem ="";
            tem+=(w.substring(0, j) + temp.charAt(i) + w.substring(j , w.length()));
            if(tem.equals(reverse(tem)))
                return tem;
          }
      }
      return "NA";
  }

}

import java.awt.*;
import java.awt.geom.Area;
import java.io.*;
import java.lang.reflect.Array;
import java.math.*;
import java.sql.SQLException;
import java.util.*;
import java.util.Map.Entry;

import javax.management.RuntimeErrorException;

import static java.lang.Math.*;

public class Solution implements Runnable {
        final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
        BufferedReader in;
        PrintWriter out;
        StringTokenizer tok = new StringTokenizer("");
        String delim = " ";

        String readString() throws IOException {
        	try {
	    		while(!tok.hasMoreTokens()) {
	    			tok = new StringTokenizer(in.readLine());
		        }
		        return tok.nextToken(delim);
	    	}
        	catch (Exception e){
        		return null;
	    	}
        }

        int readInt() throws IOException{
            return Integer.parseInt(readString());
        }
        long readLong() throws IOException{
            return Long.parseLong(readString());
        }
        double readDouble() throws IOException{
            return Double.parseDouble(readString());
        }
        Point readPoint() throws IOException {
        	return new Point(readInt(), readInt());
        }
        char readChar() throws IOException{
        	int x = 0;
        	while ((x = in.read()) == '\n' || x == '\r' || x == ' '){ }
        	return (char)x;
        }
//----------------------------------
        public class Three {
            public int a, b, c;
            public Three(){}
            public Three(int a, int b, int c){this.a = a;this.b=b;this.c=c;}
            public String toString(){
                return a + ":" + b + ":" + c;
            }
        }
//----------------------------------------

        char[] getAns(char[] s, int n){

        	int placePos = -1;
        	char c = 0;
        	for (int i = 0; i < n/2; i++){
        		if (s[i] != s[n-1-i]){
        			placePos = n-i;
        			c = s[i];
        			break;
        		}
        	}

        	if (placePos == -1) {
        		placePos = n/2;
				c = s[placePos];
        	}

        	if (placePos == -1) return null;

        	char[] ans = new char[s.length+1];
        	for (int i = 0; i < placePos; i++){
        		ans[i] = s[i];
        	}
        	ans[placePos] = c;
        	for (int i = placePos+1; i < n+1;i++){
        		ans[i] = s[i-1];
        	}

        	for (int i = 0; i < (n+1)/2; i++){
        		if (ans[i] != ans[n-i]){
        			return null;
        		}
        	}

        	return ans;
        }

        void solve() throws IOException {
        	char[] s = readString().toCharArray();

        	char[] ss = new char[s.length];
        	for (int i = 0; i < s.length; i++){
        		ss[s.length-1-i] = s[i];
        	}

        	char[] a = getAns(s, s.length);
        	char[] aa = getAns(ss, s.length);

        	if (a == null && aa == null){
        		out.println("NA");
        		return;
        	}
        	if (a != null){
        		for (int i = 0; i < a.length; i++){
        			out.print(a[i]);
        		}
        		return;
        	}
        	if (aa != null){
        		for (int i = 0; i < aa.length; i++){
        			out.print(aa[i]);
        		}
        		return;
        	}
        }

//----------------------------------------
        public static void main(String[] args){
            new Thread(null, new Solution(), "", 256 * (1L << 20)).start();
        }

        public void run(){
                try{
                        timeBegin = System.currentTimeMillis();

                        try{
                            if (ONLINE_JUDGE){
                                in = new BufferedReader(new InputStreamReader(System.in));
                                out = new PrintWriter(System.out);
                            }
                            else {
                            	in = new BufferedReader(new FileReader("input.txt"));
                            	out = new PrintWriter("output.txt");
                            }
                        }catch(Throwable e){
                            in = new BufferedReader(new InputStreamReader(System.in));
                            out = new PrintWriter(System.out);
                        }

                        solve();
                        out.close();

                        timeEnd = System.currentTimeMillis();
                        System.err.println("Time = " + (timeEnd - timeBegin));
                }catch (Exception e){
                        e.printStackTrace(System.err);
                        System.exit(-1);
                }
        }

        long timeBegin, timeEnd;
}

public class Main {
    public static void main(String[] args){

        java.util.Scanner input = new java.util.Scanner(System.in);
        String s = input.next();
        int l = s.length();

        if(p(s)){
            System.out.println(s.substring(0, l/2) + s.charAt(l/2) + s.substring(l/2));
            System.exit(0);
        }

        for(int i = 0, j = l-1; i < l/2; i++, j--){
            if(s.charAt(i)!= s.charAt(j)){
                String s1 = s.substring(0, j+1) + s.charAt(i) + s.substring(j+1);
                String s2 = s.substring(0, i) + s.charAt(j) + s.substring(i);
                if(p(s1)){
                    System.out.println(s1);
                    System.exit(0);
                }
                if(p(s2)){
                    System.out.println(s2);
                    System.exit(0);
                }
                break;
            }
        }

        System.out.println("NA");
    }

    public static boolean p(String s){
        for(int i = 0, j = s.length() - 1; i < s.length(); i++, j--)
            if(s.charAt(i)!= s.charAt(j))
                return false;

        return true;
    }
}

import java.util.Scanner;

public class KitayutaGift {
	public static String voltear(String s){
		String k="";
		for (int i = s.length()-1; i >= 0 ; i--) {
			k+=s.charAt(i);
		}
		return k;
	}
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		String s2=s;
		int t=0;
		while(true){
			int j=s.length()-1,k=0;
			for (int i = 0; i < j; i++) {
				if(s.charAt(i)==s.charAt(j)){
					j--;
				}
				else{
					s=s.substring(0,j+1)+s.charAt(i)+s.substring(j+1,s.length());
					k++;
				}
				if(k>1)break;
			}
			if(k==1){
				System.out.println(s);break;
			}
			else{
				int n=s.length()/2;
				if(k==0){
					s=s.substring(0,n)+s.charAt(n)+s.substring(n,s.length());
					System.out.println(s);break;
				}
				else{
					s=voltear(s2);
				}
			}
			t++;
			if(t>=2){
				System.out.println("NA");break;
			}
		}

	}

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Palindrome {

    static String reverse(String word)
    {

        char[] wordArray=new char[word.length()];
        int length=word.length();
        for(int i=length-1;i>=0;i--)
        {
            wordArray[length-1-i]=word.charAt(i);

        }

        String reversedWord=new String(wordArray);

        return reversedWord;

    }

    static String palindromizer(String word)
    {
        StringBuilder sb=new StringBuilder(word);

        if(word.equals(reverse(word)))
        {
            if(word.length()%2==0)
            {
                sb.insert(word.length()/2, 'a');
                word=sb.toString();
            }
            else
            {
                sb.insert(word.length()/2,word.charAt(word.length()/2));
                word=sb.toString();
            }
        }
        else
        {
            if(word.length()==2)
            {
                sb.insert(2, word.charAt(0));
                word=sb.toString();
            }
            else
            {
                String firstSubstring=word.substring(0, word.length()/2+1);
                String secondSubstring=reverse(word.substring(word.length()/2+1));

                StringBuilder builder=new StringBuilder(secondSubstring);
                int flag=0;
                for(int i=0;i<secondSubstring.length();i++)
                    if(firstSubstring.charAt(i)!=secondSubstring.charAt(i))
                    {

                        builder.insert(i, firstSubstring.charAt(i));
                        flag=1;
                        String palindromeCheck=reverse(builder.toString());

                        if((firstSubstring+palindromeCheck).equals(reverse(firstSubstring+palindromeCheck)))
                        {
                            word=firstSubstring+palindromeCheck;
                            flag=2;
                            break;
                        }
                        else
                        {
                            word="NA";
                            break;
                        }

                    }

                if(flag==0)
                {
                    builder.insert(secondSubstring.length(), firstSubstring.charAt(firstSubstring.length()-2));
                    String palindromeCheck=reverse(builder.toString());
                        if((firstSubstring+palindromeCheck).equals(reverse(firstSubstring+palindromeCheck)))
                        {
                            word=firstSubstring+palindromeCheck;

                        }
                        else
                        {
                            word="NA";

                        }
                }

            }

        }

        return word;
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String word=br.readLine();

        String firstSolution=palindromizer(word);
        String secondSolution=palindromizer(reverse(word));

            if(!(firstSolution.equals("NA"))&&secondSolution.equals("NA"))
                System.out.print(firstSolution);

            if(!(secondSolution.equals("NA"))&&firstSolution.equals("NA"))
                System.out.print(secondSolution);

            if(firstSolution.equals("NA")&&secondSolution.equals("NA"))
                System.out.print(firstSolution);

            if(!(firstSolution.equals("NA"))&&!(secondSolution.equals("NA")))
                System.out.print(firstSolution);

    }

}

import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.math.BigInteger;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author minhthai
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        String s = in.next();
        int n = s.length();
        if(isPalind(s) && n % 2 == 0) {
            String z = s.substring(0, n / 2);
            out.println(s.substring(0, n / 2) + "y" + s.substring(n / 2, n));
            return;
        }

        for(int i = 0; i < n; ++i) {
            char c = s.charAt(i);
            StringBuilder sb = new StringBuilder(s);
            String k = sb.deleteCharAt(i).toString();
            if(isPalind(k)) {
                StringBuilder ans = new StringBuilder(s);
                ans.insert(n - 1 - i, c);
                if(!isPalind(ans.toString()))
                    ans.deleteCharAt(n - 1 - i).insert(n - i, c);
                out.println(ans);
                return;
            }
        }
        out.println("NA");
    }

    public boolean isPalind(String s) {
        int n = s.length();
        for(int i = 0; i < n; ++i) {
            if(s.charAt(i) != s.charAt(n - 1 - i))
                return false;
        }
        return true;
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

}

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        System.out.println(find(in.nextLine().trim()));
    }
    public static String find(String start) {
        for (int i = 0; i <= start.length(); i++) {
            for (int j = 0; j < 26; j++) {
                char c = (char)('a' + j);
                String s = start.substring(0, i) + c + start.substring(i);
                if (palindrome(s)) return s;
            }
        }
        return "NA";
    }
    public static boolean palindrome(String s) {
        for (int i = 0; i < s.length() / 2; i++) {
            if (s.charAt(i) != s.charAt(s.length() - i - 1)) return false;
        }
        return true;
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class A {

    public void solve(){

        String s = in.nextLine();
        int j = s.length() -1;

        for(int i = 0; i<=s.length(); i++){
            if(i>0 && i == s.length() /2){
                j++;
            }
            String t = s.substring(0, i) + s.charAt(j--) + s.substring(i);
            if(isPali(t)){
                out.println(t);
                return;
            }
        }
        out.println("NA");

    }

    public boolean isPali(String s){
        int j = s.length() -1;

        for(int i = 0; i<j; i++){
            if(s.charAt(i) != s.charAt(j)){
                return false;
            }
            j--;
        }
        return true;

    }

//  public void solve(){
//
//      String s = in.nextLine();
//      int j = s.length() -1;
//      boolean flag = false;
//
//      int ind = -1;
//      String c = "";
//      boolean left = false;
//      for(int i = 0; i<j; i++){
//          if(s.charAt(i) != s.charAt(j)){
//              if(flag){
//
//                  other(s);
//                  return;
//              }
//              else if( i <= j - 1 && s.charAt(i) == s.charAt(j-1)){
//                  ind = i;
//                  left = true;
//                  c = Character.toString(s.charAt(j));
//                  j--;
//                  flag = true;
//              }
//              else if( i+1 <= j && s.charAt(i+1) == s.charAt(j)){
//                  ind = j;
//                  c = Character.toString(s.charAt(i));
//                  i++;
//                  flag = true;
//              }
//
//              else{
//                  other(s);
//                  out.flush();
//                  return;
//              }
//
//          }
//          j--;
//      }
//
//      if(flag){
//          if(left){
//              out.println(s.substring(0, ind ) + c + s.substring(ind));
//          }
//          else{
//              out.println(s.substring(0, ind + 1) + c + s.substring(ind + 1));
//          }
//      }
//      else if(s.length() % 2 == 0){
//          out.println(s.substring(0,s.length() /2 ) + "a" + s.substring(s.length() /2 ));
//      }
//      else {
//          out.println(s.substring(0, j+1) + s.charAt(j) + s.substring( j+1));
//      }
//
//
//  }
//
//  public void other(String s){
//      int j = s.length() -1;
//      boolean flag = false;
//
//      int ind = -1;
//      String c = "";
//      boolean left = false;
//      for(int i = 0; i<j; i++){
//          if(s.charAt(i) != s.charAt(j)){
//              if(flag){
//                  out.println("NA");
//                  out.flush();
//                  return;
//              }
//              else if( i+1 <= j && s.charAt(i+1) == s.charAt(j)){
//                  ind = j;
//                  c = Character.toString(s.charAt(i));
//                  i++;
//                  flag = true;
//              }
//              else if( i <= j - 1 && s.charAt(i) == s.charAt(j-1)){
//                  ind = i;
//                  left = true;
//                  c = Character.toString(s.charAt(j));
//                  j--;
//                  flag = true;
//              }
//              else{
//                  out.println("NA");
//                  out.flush();
//                  return;
//              }
//
//          }
//          j--;
//      }
//      if(flag){
//          if(left){
//              out.println(s.substring(0, ind ) + c + s.substring(ind));
//          }
//          else{
//              out.println(s.substring(0, ind + 1) + c + s.substring(ind + 1));
//          }
//      }
//      else if(s.length() % 2 == 0){
//          out.println(s.substring(0,s.length() /2 ) + "a" + s.substring(s.length() /2 ));
//      }
//      else {
//          out.println(s.substring(0, j+1) + s.charAt(j) + s.substring( j+1));
//      }
//  }
//
    public static void main(String[] args){
        A m = new A();
        m.solve();
        m.out.flush();
        m.out.close();
    }

    InputStream inputStream;
    OutputStream outputStream;
    InputReader in;
    PrintWriter out;

    public A(){
        inputStream = System.in;
        outputStream = System.out;
        in = new InputReader(inputStream);
        out = new PrintWriter(outputStream);
    }

}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken();
    }
    public String nextLine(){
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        String s = "";
        while(tokenizer.hasMoreTokens()){
            s += tokenizer.nextToken();
            if(tokenizer.hasMoreTokens()){
                s+=" ";
            }
        }

        return s;

    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
    public double nextDouble(){
        return Double.parseDouble(next());
    }

    public long nextLong(){
        return Long.parseLong(next());
    }

    public float nextFloat(){
        return Float.parseFloat(next());
    }

}

import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws java.lang.Exception {
	java.io.BufferedReader r = new java.io.BufferedReader(new java.io.InputStreamReader (System.in));

	String str = r.readLine();
	String orig = str;
	String rev = new StringBuffer(str).reverse().toString();

	int len = str.length();
	int index = -1;
	for(int i = 0; i < len; i++) {
	    if(str.charAt(i) != rev.charAt(i)) {
		index = i;
		break;
	    }
	}

	if(index != -1) {
	    rev = rev.substring(0, index) + str.charAt(index) + rev.substring(index, len);
	    str = new StringBuffer(rev).reverse().toString();
	    if(str.equals(rev))
		prnt(str);
	    else {
		str = orig;
		rev = new StringBuffer(str).reverse().toString();
		str = str.substring(0, index) + rev.charAt(index) + str.substring(index, len);
		rev = new StringBuffer(str).reverse().toString();
		if(str.equals(rev))
		    prnt(str);
		else
		    prnt("NA");
	    }
	}
	else {
	    if(len%2  == 0)
		str = str.substring(0, len/2) + "a" + str.substring(len/2, len);
	    else
		str = str.substring(0, len/2 + 1) + str.charAt(len/2) + str.substring(len/2 + 1, len);
	    prnt(str);
	}

    }

    public static void prnt(String s) {
	System.out.println(s);
    }
    public static void prnt(int s) {
	System.out.println(s);
    }
    public static void prnt(double s) {
	System.out.println(s);
    }
    public static void prnt(long s) {
	System.out.println(s);
    }
    public static void prnt(char s) {
	System.out.println(s);
    }
    public static int toInt(String s) {
	return Integer.parseInt(s);
    }
    public static long toLong(String s) {
	return Long.parseLong(s);
    }
}

import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.MathContext;

import javax.swing.plaf.synth.SynthSeparatorUI;

import org.xml.sax.HandlerBase;

import java.util.*;

public class Main {

	static final int mod=(int)1e9+7;
	public static void main(String[] args) {
        FasterScanner s = new FasterScanner();
        PrintWriter out=new PrintWriter(System.out);

        String in=s.nextLine();
        String first="";

        String second=in;

       while(true){
        	for(int j=0;j<26;j++){
        		if(isPalin(first+(char)(j+'a')+second))
        		{
        			System.out.println(first+(char)(j+'a')+second);
        			return;
        		}
        	}
        	if(second.equals(""))
        		break;
        	first=first+second.charAt(0);

        	second=second.substring(1);
        }
        System.out.println("NA");
        out.close();
    }
    static boolean isPalin(String s){
    	for(int i=0,j=s.length()-1;i<s.length()/2;i++,j--){
    		if(s.charAt(i)!=s.charAt(j))
    			return false;
    	}
    	return true;
    }

    static class Pair<A extends Comparable<A> , B extends Comparable<B>>implements Comparable<Pair>{
    	A a;
    	B b;
    	public Pair(A a ,B b){ this.a =a; this.b = b; }

		public int compareTo(Pair o) {
			int res = a.compareTo((A) (o.a));
			if(res == 0)
				res = b.compareTo((B)(o.b));
			return res;
		}

    }

    static class Node
    {
    	int id=0;
    	char ch;
    	boolean done=false;
    	Node l,r;
    	int parent=0;
    	Node(char ch){ this.ch=ch;}

    }
    static int gcd (long m, long n){
        long x;
        long y;
        while(m%n != 0){
            x = n;
            y = m%n;
            m = x;
            n = y;
        }
        return (int) n;
    }

    public static class st {

	    int n;
	    long[] val;
	    int[] index;
	    void build(long [] t) {  // build the tree
	       this.n=t.length;
	       val = new long[2*n];
	       index = new int[2*n];

	       for(int i=0;i<n;i++){
	    	   val[n+i] = t[i];
	    	   index[n+i] = i;
	       }
	       for(int i=n-1;i>=0;i--){
	    	   if(val[2*i]>val[2*i+1]){
	    		   val[i] = val[2*i];
	    		   index[i]= index[2*i];
	    	   }
	    	   else{
	    		   val[i] = val[2*i+1];
	    		   index[i]= index[2*i+1];
	    	   }
	       }
	    }

	    int query(int l, int r) {  // sum on interval [l, r)
	    	int res=0;
	    	long max=0;
	    	for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
	    		if ((l&1)!=0) {
	    			if(val[l]>max){
	    				max=val[l];
	    				res = index[l];
	    			}
	    			l++;
	    		}
	            if ((r&1)!=0){
	            	--r;
	            	if(val[r]>max){
	    				max=val[r];
	    				res = index[r];
	    			}
	            }
	        }
	    	return res;
	    }
	}

    public static class FasterScanner {
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = System.in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        public long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
    }
}

import java.util.*;
import static java.lang.System.out;
import static java.lang.Math.*;

public class T {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		String t = "";
		for (int i = 0; i <= s.length(); ++i) {
			for (char ch = 'a'; ch <= 'z'; ++ch) {
				t = s.substring(0, i) + ch + s.substring(i);
				if (palin(t)) {
					out.println(t);
					return;
				}
			}
		}
		out.println("NA");
	}
	static boolean palin(String s) {
		int i = 0;
		int j = s.length()-1;
		while (i < j) {
			if (s.charAt(i) != s.charAt(j)) {
				return false;
			}
			++i; --j;
		}
		return true;
	}
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main{
public static long mod = 1000000007;
public static int map[][];
public static int dx[] = {0,1,1,1,0,-1,-1,-1};
public static int dy[] = {-1,-1,0,1,1,1,0,-1};
public static void main(String args[]) throws IOException{
BufferedReader lector = new BufferedReader(new InputStreamReader(System.in));
String t = lector.readLine();
//StringBuilder sb = new StringBuilder("");
if(t.length()<2){System.out.println(t+t);return;}
for(int n = 0;n<=t.length();n++){
String tt = t.substring(0,n)+
((t.length())%2==0 && n==(t.length())/2?"a":t.charAt(t.length()-n-(n<t.length()/2?1:0)))+
(n<t.length()?t.substring(n):"");
boolean es = true;
//System.out.println("-->"+tt);
for(int m = 0;m<tt.length();m++)
if(tt.charAt(m)!=tt.charAt(tt.length()-1-m))es=false;
if(es){
System.out.println(tt);
return;
}
}

System.out.println("NA");
}
}

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Solution_505A {
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        char[] chars = reader.readLine().toCharArray();
        int sz = chars.length;
        char[] out = new char[sz + 1];
        int ins = 0;

        out[sz / 2] = chars[sz / 2];

        for (int i = 0; i < out.length / 2; i++) {
            out[i] = chars[i];
            out[sz - i] = chars[i];
            if(chars[i] != chars[sz - i - 1 + ins]) ins++;
            if (ins > 1) break;
        }

        if (ins > 1) {
            ins = 0;
            for (int i = out.length - 1; i >= out.length / 2; i--) {
                out[i] = chars[i - 1];
                out[sz - i] = chars[i - 1];
                if(chars[i - 1] != chars[sz - i - ins]) ins++;
                if (ins > 1) break;
            }
        }

        if(ins <= 1) {
            for (char ch : out)
                System.out.print("" + ch);
            System.out.println();

        } else
            System.out.println("NA");
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Solution_505A {
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        char[] chars = reader.readLine().toCharArray();
        int sz = chars.length;
        char[] out = new char[sz + 1];
        int ins = 0;

        out[sz / 2] = chars[sz / 2];

        for (int i = 0; i < out.length / 2; i++) {
            out[i] = chars[i];
            out[sz - i] = chars[i];
            if(chars[i] != chars[sz - i - 1 + ins])
                ins++;
            if (ins > 1) {
                ins = 0;
                for (i = out.length - 1; i >= out.length / 2; i--) {
                    out[i] = chars[i - 1];
                    out[sz - i] = chars[i - 1];
                    if(chars[i - 1] != chars[sz - i - ins])
                        ins++;
                    if (ins > 1)
                        break;
                }
                break;
            }
        }

        if(ins <= 1) {
            for (char ch : out)
                System.out.print("" + ch);
            System.out.println();

        } else
            System.out.println("NA");
    }
}

import java.io.IOException;

/**
 * Created by kaaveh on 1/22/15.
 */

/**                       _
* _._ _..._ .-',     _.._(`))
*'-. `     '  /-._.-'    ',/
*   )         \            '.         Hi! I'm piggy! ;)
*  / _    _    |             \
* |  a    a    /              |
* \   .-.                     ;
*  '-('' ).-'       ,'       ;
*     '-;           |      .'
*        \           \    /
*        | 7  .__  _.-\   \
*        | |  |  ``/  /`  /
*       /,_|  |   /,_/   /
*          /,_/      '`-'
*/

public class _505A_ {
    public static void main(String[] args) {   //I hope enjoy! :)

        kaaveh in = new kaaveh();
        String data = in.kLine(10);

        int size = data.length() / 2;
        int lng= data.length();
        String res = "";
        String ress = "";
        boolean palin1 = true;
        boolean palin2 = true;

        for (int i=0; i<size; i++){
            if (data.charAt(i) != data.charAt(lng-1-i)){
                res += data.substring(0,lng-i);
                res += data.charAt(i);
                res += data.substring(lng - i, lng);
                ress += data.substring(0, i);
                ress += data.charAt(lng-1-i);
                ress += data.substring(i, lng);
                break;
            }
        }

        if (res.equals("")){
            if (lng % 2 == 0){
                System.out.println(data.substring(0, size) + "a" + data.substring(size, lng));
            }else {
                System.out.println(data.substring(0, size) + data.charAt(size) + data.substring(size, lng));
            }
            System.exit(0);
        }
        size = lng+1/2;

        for (int i=0; i<size; i++){
            if (res.charAt(i) != res.charAt(lng-i)){
                palin1 = false;
            }
            if (ress.charAt(i) != ress.charAt(lng-i)){
                palin2 = false;
            }
        }
        if (palin1)
            System.out.println(res);
        else if (palin2)
            System.out.println(ress);
        else
            System.out.println("NA");
    }
}

class kaaveh{
    static String kLine (int maxLg)
    {
        byte lin[] = new byte [maxLg];
        int lg = 0, car = -1;
        String line = "";

        try
        {
            while (lg < maxLg)
            {
                car = System.in.read();
                if ((car < 0) || (car == '\n') || (car == '\r')) break;
                lin [lg++] += car;
            }
        }
        catch (IOException e)
        {
            return (null);
        }

        if ((car < 0) && (lg == 0)) return (null);  // eof
        return (new String (lin, 0, lg));
    }

    static String knex (int maxLg)
    {
        byte lin[] = new byte [maxLg];
        int lg = 0, car = -1;
        String line = "";

        try
        {

            while ((car < 0) || (car == '\n') || (car == ' ') || (car == '\t') || (car == '\r'))
                car = System.in.read();

            while (lg < maxLg)
            {
                if ((car < 0) || (car == '\n') || (car == ' ') || (car == '\t') || (car == '\r')) break;
                lin [lg++] += car;
                car = System.in.read();
            }
        }
        catch (IOException e)
        {
            return (null);
        }

        if ((car < 0) && (lg == 0)) return (null);  // eof
        return (new String (lin, 0, lg));
    }

    static int kint()
    {
        return Integer.parseInt(knex(11));
    }

    static long kLong()
    {
        return Long.parseLong(knex(20));
    }

    static double kdouble()
    {
        return Double.parseDouble(knex(100));
    }
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

/*
public class _505A {

}

 */

public class _505A {
	public void solve() throws FileNotFoundException {
		InputStream inputStream = System.in;

		InputHelper inputHelper = new InputHelper(inputStream);

		PrintStream out = System.out;

		//actual solution

		String s = inputHelper.read();

		int n = s.length();

		for(int i = 0; i < 26; i++)
		{
			char c = (char)('a' + i);
			for(int j = 0; j <= n; j++)
			{
				String ft = s.substring(0, j);
				String st = s.substring(j);

				String t = ft + c + st;

				if(isP(t))
				{
					out.println(t);
					return;
				}
			}
		}
		out.println("NA");
		//end here
	}

	private boolean isP(String t) {
		int n = t.length();

		for(int i = 0, j = n - 1; i < n/2; i++, j--)
		{
			if(t.charAt(i) != t.charAt(j))
			{
				return false;
			}
		}

		return true;
	}

	public static void main(String[] args) throws FileNotFoundException {
		(new _505A()).solve();
	}

	class InputHelper {
		StringTokenizer tokenizer = null;
		private BufferedReader bufferedReader;

		public InputHelper(InputStream inputStream) {
			InputStreamReader inputStreamReader = new InputStreamReader(
					inputStream);
			bufferedReader = new BufferedReader(inputStreamReader, 16384);
		}

		public String read() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					String line = bufferedReader.readLine();
					if (line == null) {
						return null;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

			return tokenizer.nextToken();
		}

		public Integer readInteger() {
			return Integer.parseInt(read());
		}

		public Long readLong() {
			return Long.parseLong(read());
		}
	}
}

import java.util.*;
import java.io.*;

public class gift {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		char[] input = in.nextLine().toCharArray();
		ArrayList<Character> chars = new ArrayList<>();
		for(char c: input) {
			chars.add(c);
		}
		boolean done = false;
		loop:
		for(int i = 0; i <= chars.size(); i++) {
			for(char c = 'a'; c <= 'z'; c++) {
				chars.add(i, c);
				if(isPal(chars)) {
					done = true;
					for(char letter: chars) {
						System.out.print(letter);
					}
					System.out.println();
					break loop;
				}
				chars.remove(i);
			}
		}
		if(!done) {
			System.out.println("NA");
		}
	}

	public static boolean isPal(ArrayList<Character> chars) {
		for(int i = 0; i <= chars.size() / 2; i++) {
			if(chars.get(i) != chars.get(chars.size() - i - 1)) {
				return false;
			}
		}
		return true;
	}
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Solution  {

	static class FastScanner{
		BufferedReader s;
		StringTokenizer st;

		public FastScanner(){
			st = new StringTokenizer("");
			s = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(File f) throws FileNotFoundException{
			st = new StringTokenizer("");
			s = new BufferedReader (new FileReader(f));
		}

		public int nextInt() throws IOException{
			if(st.hasMoreTokens())
				return Integer.parseInt(st.nextToken());
			else{
				st = new StringTokenizer(s.readLine());
				return nextInt();
			}
		}

		public double nextDouble() throws IOException{
			if(st.hasMoreTokens())
				return Double.parseDouble(st.nextToken());
			else{
				st = new StringTokenizer(s.readLine());
				return nextDouble();
			}
		}

		public long nextLong() throws IOException{
			if(st.hasMoreTokens())
				return Long.parseLong(st.nextToken());
			else{
				st = new StringTokenizer(s.readLine());
				return nextLong();
			}
		}

		public String nextString() throws IOException{
			if(st.hasMoreTokens())
				return st.nextToken();
			else{
				st = new StringTokenizer(s.readLine());
				return nextString();
			}

		}
		public String readLine() throws IOException{
			return s.readLine();
		}

		public void close() throws IOException{
			s.close();
		}

	}

	//FastScanner s = new FastScanner(new File("input.txt"));       copy inside void solve
    //PrintWriter ww = new PrintWriter(new FileWriter("output.txt"));
    static FastScanner s = new FastScanner();
    static PrintWriter ww = new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String args[])throws IOException{
    	//Main ob=new Main();
    	Solution ob=new Solution();
		ob.solve();
			ww.close();
    }
    ///////////////////////////////////

    //////////////////////////////

    void solve() throws IOException{
    	String str=s.readLine();
    	for(int i=97;i<=122;i++){
    		char ch=(char)i;
    		for(int j=0;j<=str.length();j++){
    			StringBuffer sb=new StringBuffer(str);
    			sb.insert(j,ch);
    			if(sb.toString().equals(sb.reverse().toString())){
    				ww.println(sb);
    				return;
    			}

    		}
    	}
    	ww.println("NA");

    } //solve

}

import java.util.Scanner;

/**
 * Created by sanjayarvind on 05/02/2017 AD.
 */
public class CR286 {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next(), temp = "";
        boolean found = false;
        int i = 0, n = s.length();
        for (i = 0; i <= n; i++) {
            for (char ch = 'a'; ch <= 'z'; ch++) {
                temp = s.substring(0, i) + ch + s.substring(i);
                if (isPalin(temp)) {
                    System.out.println(temp);
                    found = true;
                    break;
                }
                //System.out.println(temp);
            }
            if (found) break;
        }
        if (!found) System.out.println("NA");
    }

    private static boolean isPalin(String s) {
        int i = 0, j = s.length() - 1;
        while (i != j && i < j) {
            if (s.charAt(i) != s.charAt(j)) return false;
            i++;
            j--;
        }
        return true;
    }
}

import java.util.Arrays;
import java.util.Scanner;

public class P5 {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String s = in.nextLine() + ' ';
        char[] c = s.toCharArray();
        boolean check = false;
        for (int i = 0; i < s.length(); i++) {
            for (int j = 97; j < 123; j++) {
                c = s.toCharArray();
                for (int k = s.length() - 1; k > i; k--) {
                    c[k] = c[k - 1];
                }
                c[i] = (char) j;
                if (checkPalindrome(String.valueOf(c))) {
                    System.out.println(String.valueOf(c));
                    check = true;
                    break;
                }
//                System.out.println(String.valueOf(c));
            }
            if (check == true) {
                break;
            }
        }
        if (check == false) {
            System.out.println("NA");
        }
    }

    public static boolean checkPalindrome(String s) {
        // reverse the given String
        String reverse = new StringBuffer(s).reverse().toString();

        // check whether the string is palindrome or not
        return s.equals(reverse);
    }

}

import java.util.LinkedList;
import java.util.Scanner;

public class Main {

    static int check(String ss){
        char s[] = ss.toCharArray();
        for (int i = 0; i < s.length; i++) {
            if(s[i] != s[s.length-i-1])
                return i;
        }
        return -1;
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.nextLine();
        LinkedList<Character> l = new LinkedList<Character>();
        for (int i = 0; i < s.length(); i++) {
            l.add(s.charAt(i));
        }
        int x = (check(s));
        if(x == -1 && s.length()%2==0)
            l.add(s.length()/2 ,'a');
        else if(x == -1)
            l.add(s.length()/2+1,s.charAt(s.length()/2));
        else
            l.add(s.length()-x,s.charAt(x));
        String z ="";
        for (int i = 0; i < l.size(); i++) {
            z += l.get(i);
        }
        if(check(z)==-1)
            System.out.println(z);
        else{
            l = new LinkedList<Character>();
            for (int i = 0; i < s.length(); i++) {
                l.add(s.charAt(i));
            }
            l.add(x,s.charAt(s.length()-x-1));
            z ="";
            for (int i = 0; i < l.size(); i++) {
                z += l.get(i);
            }
            if(check(z)==-1)
                System.out.println(z);
            else
                System.out.println("NA");
        }

    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.nio.file.attribute.AclEntry.Builder;
import java.util.Scanner;

public class P505_A {

	private static StreamTokenizer inputReader = new StreamTokenizer(
			new BufferedReader(new InputStreamReader(System.in)));

	private static Scanner scaner = new Scanner(System.in);

	static java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));

	public static int nextInt() {
		int a = -1;
		try {
			inputReader.nextToken();
			a = (int) inputReader.nval;
		} catch (Exception e) {
		}
		return a;
	}

	public static void main(String[] args) throws IOException {
		String line = reader.readLine();

		StringBuilder builder = null;
		for (int i = 0; i < line.length(); i++) {
			String string = line.substring(0, i) + line.substring(i + 1);

			if (isPalindrome(string)) {
				builder = new StringBuilder(line);

//				System.out.println(string);
				if (i <= line.length() / 2) {
					builder.insert(line.length() - i, line.charAt(i));
				}else {
					builder.insert(line.length() - i - 1, line.charAt(i));
				}
				System.out.println(builder);
				return;
			}
		}

		System.out.println("NA");
	}

	private static boolean isPalindrome(String line) {
		for (int i = 0; i < line.length() / 2; i++) {
			if (line.charAt(i) != line.charAt(line.length() - i - 1)) {
				return false;
			}
		}

		return true;
	}

}

import java.util.*;
import java.io.*;

public class Palindromes
{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String str = in.nextLine();

		while(!str.isEmpty()) {
			boolean letterAdded = false;

			for(int i = 0; i < str.length()/2; i++) {
				int j = str.length() - i - 1;
				if(str.charAt(i) != str.charAt(j)) {
					if(letterAdded) {
						str = "";
					}
					else {
						str = addLetter(str, i, j);
						letterAdded = true;
					}
				}
			}

			if(str.isEmpty()) {
				System.out.println("NA");
			}
			else if(letterAdded) {
				System.out.println(str);
			}
			else {
				str = str.substring(0, str.length()/2) + str.charAt(str.length()/2) + str.substring(str.length()/2);
				System.out.println(str);
			}
			if(in.hasNextLine()) {
				str = in.nextLine();
			}
			else {
				str = "";
			}
		}
	}

	public static String addLetter(String str, int i, int j) {
		/*if(str.charAt(i + 1) == str.charAt(j)) {
			System.out.println("one");
			return str.substring(0, j+1) + str.charAt(i) + str.substring(j+1);
		}
		else if(str.charAt(i) == str.charAt(j - 1)) {
			System.out.println("two");
			return str.substring(0, i) + str.charAt(j) + str.substring(i);
		}
		return "";*/
		StringBuilder reverser = new StringBuilder(str);
		String reverse = reverser.reverse().toString();

		String temp1 = str.substring(0, i) + reverse.charAt(i) + str.substring(i);
		String temp2 = reverse.substring(0, j+1) + reverse.charAt(i) + reverse.substring(j+1);
		if(temp1.equals(temp2))
			return temp1;

		temp1 = reverse.substring(0, i) + str.charAt(i) + reverse.substring(i);
		temp2 = str.substring(0, j+1) + str.charAt(i) + str.substring(j+1);
		if(temp1.equals(temp2))
			return temp1;

		return "";
	}
}

//revive
//eviver

import java.util.Scanner;

/**
 * Created by yakoub on 18/01/15.
 */
public class firstSolution {
    public static boolean isPalindrome(String str) {
        if (str.length() <= 1)
            return true;
        return (str.charAt(0) == str.charAt(str.length() - 1)) && (isPalindrome(str.substring(1, str.length() - 1)));
    }

    public static String normalize(String str) {
        if (str.length() == 1)
            return str + str;
        if (str.length() == 0)
            return "a";
        if (str.charAt(0) != str.charAt(str.length() - 1)) {
            if (isPalindrome(str.substring(1)))
                return str + str.charAt(0);
            else if (isPalindrome(str.substring(0, str.length() - 1)))
                return str.charAt(str.length() - 1) + str;
            else
                return "NA";
        } else {
            String s = normalize(str.substring(1, str.length() - 1));
            if (s.equals("NA"))
                return s;
            else
                return str.charAt(0) + s + str.charAt(str.length() - 1);
        }

    }

    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        System.out.println(normalize(str));
    }
}

import java.util.*;
import java.io.*;
public class Kitayuta {
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		String word=sc.next();
		int insert=0;

		int num=0;
		int front=0;
		int back=word.length()-1;
		if(word.length()==1)
		{
			System.out.println(word+word);
			System.exit(0);
		}
		char f=word.charAt(0);
		char e=word.charAt(word.length()-1);
		if(word.length()>2&&isPalli(word+f))
		{
			System.out.println(word+f);
			System.exit(0);

		}
		//System.out.println(e+word);
		if(word.length()>2&&isPalli(e+word))
		{
			System.out.println(e+word);
			System.exit(0);

		}
		char temp='z';

		while(front<word.length()/2)
		{
			if(word.charAt(front)==word.charAt(back))
			{
				front++;
				back--;
			}
			else if((word.charAt(front+1)==word.charAt(back)))
			{
				temp=(word.charAt(front));
				//arr.put(insert++,String.valueOf(word.charAt(front)));
				insert=back+1;
				num++;
				front++;
			}
			else if ((word.charAt(front)==word.charAt(back-1)))
			{
				temp=(word.charAt(back));
				num++;
				insert=front;
				back--;

			}
			else
			{

				System.out.println("NA");
				System.exit(0);
			}

		}

		if(num==0)
		{
			if(word.length()%2==0)
			{
			String ans=word.substring(0,word.length()/2)+"y"+word.substring(word.length()/2);
			System.out.println(ans);
			}
			else
			{
				System.out.println(word.substring(0,word.length()/2)+word.charAt(word.length()/2)+word.substring(word.length()/2));
			}
			}
		else if(num>1)
		{
			System.out.println("NA");
		}
		else
		{
			String ans="";
			if(insert<0)
			{
				ans=temp+word;
			}
			else
			{
			ans=word.substring(0,insert)+temp+word.substring(insert);
			}

			System.out.println(ans);
			}

	}
	public static boolean isPalli(String word)
	{
		//System.out.println(word);
		Stack st= new Stack();
		for(int i=0;i<word.length()/2;i++)
		{
			st.push(word.charAt(i));
		}
		//System.out.println(st.isEmpty());
		for(int k=word.length()/2;k<word.length();k++)
		{
			//System.out.println(st.peek());
			if (st.isEmpty()||(char)st.pop()!=word.charAt(k))
			{
				//System.out.println("WTF");
				return false;
			}
		}

		return true;

	}
}

import java.io.*;
import java.util.*;

public class A {
	public static void main(String[] args) throws IOException {
		Scanner s = new Scanner(System.in);
		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);

		StringBuilder bruteForce = new StringBuilder(f.readLine());
		String reverse = bruteForce.reverse().toString();
		bruteForce.reverse();
//		System.out.println(reverse + " " + bruteForce);
		if(bruteForce.toString().equals(reverse)) {
			if(bruteForce.length() % 2 == 0) {
				bruteForce.insert(bruteForce.length()/2, 'a');
			} else {
				char insert = bruteForce.charAt(bruteForce.length()/2);
				bruteForce.insert(bruteForce.length()/2, insert);
			}
			System.out.println(bruteForce);
			return;
		} else {
			int n = bruteForce.length();
			for(int i = 0; i <= n; i++) {
				for(int j = 'a'; j <= 'z'; j++) {
					StringBuilder newOne = new StringBuilder(bruteForce.toString());
					newOne.insert(i, (char)j);
					String rev = newOne.reverse().toString();
					newOne.reverse();
//					System.out.println(rev);
//					System.out.println(newOne);
					if(rev.equals(newOne.toString())) {
						System.out.println(newOne.toString());
						return;
					}
				}
			}
		}
		System.out.println("NA");
		out.close();
	}
}

import java.util.Scanner;

public class Main {
	private static Scanner s;

	public static boolean isPalindrome(String s) {
		  int n = s.length();
		  for (int i=0;i<(n / 2) + 1;++i) {
		     if (s.charAt(i) != s.charAt(n - i - 1)) {
		         return false;
		     }
		  }

		  return true;
		}

	public static void main(String[] args) {
		s = new Scanner(System.in);
		String First=s.next(), Edit="" ;
		int i,t;
		boolean v = true;
		char[] alphabet = "abcdefghijklmnopqrstuvwxyz".toCharArray();
		for (i=0;(i<=First.length())&&v;i++)
		{
			for (t=0;(t<26)&&v;t++)
			{
				Edit=First.substring(0,i)+(alphabet[t])+First.substring(i,First.length());
				if(Edit.equals(new StringBuilder(Edit).reverse().toString()))
				{
					System.out.println(Edit);
					v=false;
					return;
				}
			}

		}
		if (v)
		{
			System.out.println("NA");
		}

	}

}

import java.util.*;
import java.io.*;

public class Palindromes
{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String str = in.nextLine();

		while(!str.isEmpty()) {
			boolean letterAdded = false;

			for(int i = 0; i < str.length()/2; i++) {
				int j = str.length() - i - 1;
				if(str.charAt(i) != str.charAt(j)) {
					if(letterAdded) {
						str = "";
					}
					else {
						str = addLetter(str, i, j);
						letterAdded = true;
					}
				}
			}

			if(str.isEmpty()) {
				System.out.println("NA");
			}
			else if(letterAdded) {
				System.out.println(str);
			}
			else {
				str = str.substring(0, str.length()/2) + str.charAt(str.length()/2) + str.substring(str.length()/2);
				System.out.println(str);
			}
			if(in.hasNextLine()) {
				str = in.nextLine();
			}
			else {
				str = "";
			}
		}
	}

	public static String addLetter(String str, int i, int j) {
		/*if(str.charAt(i + 1) == str.charAt(j)) {
			System.out.println("one");
			return str.substring(0, j+1) + str.charAt(i) + str.substring(j+1);
		}
		else if(str.charAt(i) == str.charAt(j - 1)) {
			System.out.println("two");
			return str.substring(0, i) + str.charAt(j) + str.substring(i);
		}
		return "";*/
		StringBuilder reverser = new StringBuilder();
		reverser.append(str);
		reverser = reverser.reverse();
		String reverse = reverser.toString();

		String temp1 = str.substring(0, i) + reverse.charAt(i) + str.substring(i);
		String temp2 = reverse.substring(0, j+1) + reverse.charAt(i) + reverse.substring(j+1);
		if(temp1.equals(temp2))
			return temp1;
		temp1 = reverse.substring(0, i) + str.charAt(i) + reverse.substring(i);
		temp2 = str.substring(0, j+1) + str.charAt(i) + str.substring(j+1);
		if(temp1.equals(temp2))
			return temp1;
		return "";
	}
}

//revive
//eviver

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        OutputStream output = System.out;
        PrintWriter pr = new PrintWriter(output);
        try {
            StringBuilder s = new StringBuilder(br.readLine());

            for (int i = 0 ; i <= s.length() ; i ++) {
                for (char c = 'a' ; c <= 'z' ; c ++) {
                    s.insert(i, c);
                    if (new StringBuilder(s).reverse().toString().equals(s.toString())) {
                        pr.println(s);
                        pr.close();
                        System.exit(0);
                    }
s.deleteCharAt(i);
                }
            }

            pr.println("NA");
            pr.close();
        } catch (IOException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Walker
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        String s = in.next();
        for(int i = 0; i <= s.length(); i++){
            for(char j = 97; j <=122; j++){
                if(isPalindrome(s.substring(0, i ) + j + s.substring(i ))){
                    out.print(s.substring(0, i ) + j + s.substring(i ));
                    return;
                }
            }
        }
        out.print("NA");
        return;

    }

    boolean isPalindrome(String s){
        for(int i = 0; i < s.length() / 2; i++){
            if(s.charAt(i) != s.charAt(s.length() - i - 1)){
                return false;
            }
        }
        return true;
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;

import java.util.StringTokenizer;

public class Soly {

    static boolean g(String d, int h) {
        for (int j = 0, p = h; j < h + 1; j++, p--) {
            if (d.charAt(j) != d.charAt(p)) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        try (PrintWriter or = new PrintWriter(System.out)) {
            StringBuilder s = new StringBuilder(in.next());
            int h = s.length();

                String f = s.charAt(h - 1) + s.toString();
                if (g(f, h)) {
                    or.println(f);
                    return;
                }

            for (int i = 0; i < h; ++i) {
                s.insert(h - i, s.charAt(i));
                String d = s.toString();
                boolean t = g(d, h);
                if (t) {
                    or.println(d);
                    return;
                }
                s.deleteCharAt(h - i);
            }
             for (int i = 0,p=h-1; i < h; ++i,--p) {
                s.insert(i, s.charAt(p));
                String d = s.toString();
                boolean t = g(d, h);
                if (t) {
                    or.println(d);
                    return;
                }
                s.deleteCharAt(i);
            }

            or.println("NA");

        }
    }

    static class Scanner {

        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++) {
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec) {
                        f *= 10;
                    }
                }
            }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }

}

class Pair8 {

    int index;
    long value;

    // int min;
    public Pair8(int index, long value) {
        this.value = value;
        this.index = index;
        //min = m;
    }

}

import java.util.*;
import java.util.LinkedList;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class tmp {
    public static void main(String [] args) throws Exception{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
 //       StringTokenizer st = new StringTokenizer(in.readLine());
        StringBuilder sb = new StringBuilder();

        String  s = in.readLine();

        String alp = "abcdefghijklmnopqrstuvwxyz";

        for(int i=0; i<26; i++){
            for(int j=0; j<=s.length(); j++){
                sb = new StringBuilder(s);
                sb.insert(j, alp.charAt(i));
                if(sb.toString().equals(sb.reverse().toString())){
                    System.out.println(sb.toString());
                    return;
                }
            }
        }
        System.out.println("NA");

    }

}

class P implements Comparable<P>{
    int val, idx;
    public P(int val, int idx){
        this.val = val;
        this.idx = idx;
    }

    public int compareTo(P other){
        if (this.val != other.val) return -this.val + other.val;
        return this.idx - other.idx;
    }
}

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class palindrome
{
	static int inc=0;
	static boolean isPalindrome(String check)
	{
		String t="";
		for(int h=check.length()-1;h>=0;h--)
		{
			t=t.concat(Character.toString(check.charAt(h)));
		}
		//System.out.println(t+" "+check);
		if(t.equals(check))
		{
			inc++;
			//System.out.println(t+" "+check);
			//System.out.println("Check no.:"+ inc);
			return true;
		}
		else
		return false;
	}

	public static void main (String[] args) throws java.lang.Exception
	{
		String s;
		Scanner in = new Scanner(System.in);
		s=in.nextLine();
		int n=s.length();
		int i,j,flag=0,count=0;
		String m,se;
		String alpha="abcdefghijklmnopqrstuvwxyz";
			m=s;
			for(int o=0;o<alpha.length();o++)
			{
				String t="";
				t=Character.toString(alpha.charAt(o));
				//System.out.print(t);
				t=t.concat(m);
				//System.out.println(se);
				count++;
				if(isPalindrome(t))
				{
					flag=1;
					System.out.println(t);
					break;
				}
			}
			if(flag==0)
			{
			for(int o=0;o<alpha.length();o++)
			{
				String t="";
				t=Character.toString(alpha.charAt(o));
				m=m.concat(t);
				if(isPalindrome(m))
				{
					flag=1;
					System.out.println(m);
					break;
				}
			}
			}
		if(flag==0)
		{
		for(i=0;i<n;i++)
		{
			m=s.substring(0,n-i);
			se=s.substring(n-i);

			for(int o=0;o<alpha.length();o++)
			{
				String t="",store;
				t=Character.toString(alpha.charAt(o));
				store=m;
				//System.out.print(m+" ");
				//System.out.print(t+" ");
				m=m.concat(t);
				m=m.concat(se);
				//System.out.println(se);
				if(isPalindrome(m))
				{
					System.out.println(m);
					flag=1;
					break;
				}
				m=store;
			}
			if(flag==1)
			break;
		}
		}
		if(flag==0)
		System.out.println("NA");
	}
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import javafx.util.Pair;

public class Ahmed {

    public static void main(String[] args) {
             Scanner input=new Scanner (System.in);
             int count=0;
             boolean v=true;
             String s=input.next();
             if (ispalindrome(s)){
                 s = new StringBuffer(s).insert(s.length()/2,s.charAt(s.length()/2) ).toString();
             System.out.print(s);
             }

             else{
                Stack<Character>a=new Stack<>();
                for(int i=0;i<s.length();i++){
                     a.add(s.charAt(i));
                }
                String rev="";
                for(int i=0;i<s.length();i++){
                     rev=rev+a.pop();
                }

                for(int i=0;i<s.length();i++){
                    String c=s;
                    if (rev.charAt(i)!=s.charAt(i)){
                       c = new StringBuffer(s).insert(i,rev.charAt(i) ).toString();

                       if (ispalindrome(c)){
                         System.out.print(c);
                         v=false;
                         break;
                       }
            c = new StringBuffer(rev).insert(i,s.charAt(i) ).toString();
                       if (ispalindrome(c)){
                         System.out.print(c);
                         v=false;
                       }
                       else{count++;}

                    }

                }
                if(v){System.out.print("NA");}
             }
    }
    public static boolean ispalindrome(String s ){
        Stack<Character>a=new Stack<>();
        String rev="";
        for(int i=0;i<s.length();i++){
            a.add(s.charAt(i));
        }
         for(int i=0;i<s.length();i++){
           rev=rev+ a.pop();
        }
        if (rev.equals(s)){return true;}
        else{return false;}

    }

}

import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        String ss = in.next();

        outer:
        for (int i = 0; i < ss.length(); i++) {
            for (int j = 0; j < 26; j++) {
                String s = ss;
                char c = (char) (97 + j);
                s = ss.substring(0, i) + c + ss.substring(i, ss.length());

                boolean bool = check(s);
                if (bool) {
                    System.out.println(s);
                    System.exit(0);
                }
            }
        }

        for (int j = 0; j < 26; j++) {
            String s = ss;
            char c = (char) (97 + j);
            s = s + c;
            boolean bool = check(s);
            if (bool) {
                System.out.println(s);
                System.exit(0);
            }
        }

        System.out.println("NA");
    }

    static boolean check(String s) {
        for (int i = 0, j = s.length() - 1; i < s.length(); i++, j--) {
            if (s.charAt(i) != s.charAt(j)) {
                return false;
            }
        }
        return true;
    }
}

import java.util.Scanner;

public class KitayutasGift {
    public static void main(String args[]) {
        // Create a new Scanner object to read from System.in
        Scanner scan = new Scanner(System.in);

        // Read original string
        String originalString = scan.next();

        // Create a copy of original string that is to be modified
        String modifiedString = originalString;

        // Iterate through ascii values for lowercase letters
        for (int i = 97; i <= 122; i++) {
            // Iterate through positions of characters in the string
            for (int j = 0; j < modifiedString.length(); j++) {
                //Modify the string one character at a time and check whether it is a palindrome
                modifiedString = originalString.substring(0, j) + (char)i + originalString.substring(j);

                // Check to see if modified string is a palindrome
                if (isStringPalindrome(modifiedString)) {
                    // We're done! Print out contents!
                    System.out.println(modifiedString);
                    return;
                }
            }

            modifiedString = originalString;
        }

        // If we get here then nothing worked
        System.out.println("NA");
    }

    public static boolean isStringPalindrome(String s) {
        int start = 0;
        int end = s.length() - 1;

        while (start <= end) {
            // Compare characters at start and end
            if (s.charAt(start) != s.charAt(end)) {
                return false;
            }

            start++;
            end--;
        }

        return true;
    }
}

import java.util.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		String s = new String();
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()){
			s = cin.next();
			int len = s.length();
			int res = -1;
			for(int i = 0 ; i < len ; i ++){
				int l = 0 ,r = len - 1;
				int tres = 1;
				while(l <= r){
					if(l == i){
						l ++;
						continue;
					}
					if(r == i){
						r --;
						continue;
					}
					if(s.charAt(l) != s.charAt(r)) tres = 0;
					l ++;r --;
				}
				if(tres == 1) res = i;
				if(res != -1) break;
			}
			if(res == -1) System.out.println("NA");
			else{
				if(res < len / 2){
					for(int i = 0 ; i < (len + 1) / 2 ; i ++)
						System.out.print(s.charAt(i));
					if(len % 2 == 0) System.out.print(s.charAt(len / 2));
					for(int i = (len + 1) / 2 - 1 ; i >= 0 ; i --)
						System.out.print(s.charAt(i));
					System.out.println();
				}
				else{
					for(int i = 0 ; i < (len + 1) / 2 ; i ++)
						System.out.print(s.charAt(len - 1 - i));
					if(len % 2 == 0) System.out.print(s.charAt(len / 2 - 1));
					for(int i = (len + 1) / 2 - 1 ; i >= 0 ; i --)
						System.out.print(s.charAt(len - 1 - i));
					System.out.println();
				}
			}
		}
	}
}

import java.util.LinkedList;
import java.util.Scanner;

public class Main {

    static int check(String ss){
        char s[] = ss.toCharArray();
        for (int i = 0; i < s.length; i++) {
            if(s[i] != s[s.length-i-1])
                return i;
        }
        return -1;
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.nextLine();
        LinkedList<Character> l = new LinkedList<Character>();
        for (int i = 0; i < s.length(); i++) {
            l.add(s.charAt(i));
        }
        int x = (check(s));
        if(x == -1 && s.length()%2==0)
            l.add(s.length()/2 ,'a');
        else if(x == -1)
            l.add(s.length()/2+1,s.charAt(s.length()/2));
        else
            l.add(s.length()-x,s.charAt(x));
        String z ="";
        for (int i = 0; i < l.size(); i++) {
            z += l.get(i);
        }
        if(check(z)==-1)
            System.out.println(z);
        else{
            l = new LinkedList<Character>();
            for (int i = 0; i < s.length(); i++) {
                l.add(s.charAt(i));
            }
            l.add(x,s.charAt(s.length()-x-1));
            z ="";
            for (int i = 0; i < l.size(); i++) {
                z += l.get(i);
            }
            if(check(z)==-1)
                System.out.println(z);
            else
                System.out.println("NA");
        }

    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

/**
 * Created by Egor on 18/01/15.
 */
public class TaskA {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String s = reader.readLine();
        ArrayList<Character> c = new ArrayList<>();
        for (char cur : s.toCharArray()) {
            c.add(cur);
        }
        boolean x = s.length() % 2 == 0;

        for (int index = 0; index < s.length() + 1; index++) {
            if (index < s.length()) {
                int idx = s.length() - index - 1;
                if (idx < index) idx++;
                c.add(index, c.get(idx));
            } else {
                c.add(c.get(0));
            }
            if (isPalindrome(c)) {
                StringBuilder builder = new StringBuilder();
                for (char cur : c) {
                    builder.append(cur);
                }
                System.out.println(builder.toString());
                System.exit(0);
            }
            c.remove(index);
        }
        System.out.println("NA");
    }

    public static boolean isPalindrome(ArrayList<Character> c) {
        int n = c.size();
        for (int i = 0; i < n; i++) {
            if (!c.get(i).equals(c.get(n - i - 1))) {
                return false;
            }
        }
        return true;
    }

}

import java.util.Scanner;

/**
 * Created by markdaniel on 1/29/16.
 */
public class Exercise2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        if (scanner.hasNextLine()) {
            System.out.println(doKitayuta(scanner.nextLine()));
        }
    }

    public static String doKitayuta(String word) {
        int wordLen = word.length();
        StringBuilder sb = new StringBuilder();
        if (wordLen == 1) {
            return sb.append(word + word).toString();
        }
        if (wordLen == 2) {
            if (word.charAt(0) == word.charAt(1)) {
                return sb.append("" + word.charAt(0) + 'x' + word.charAt(1)).toString();
            } else {
                return sb.append(word.charAt(1) + word).toString();
            }
        }

        int start = 0;
        int end = wordLen - 1;

        word = recurse(word, start, end, false);

        return word;
    }

    public static String recurse(String word, int start, int end, boolean affixed) {
        int wordLen = word.length();
        StringBuilder sb = new StringBuilder();
        char startChar = word.charAt(start);
        char endChar = word.charAt(end);

//abbabab

        if ((end - start) <= 1) {
            if (end == start && !affixed) {
                word = sb.append(word.substring(0, start + 1) + word.charAt(start) + word.substring(start + 1, wordLen)).toString();
            } else if (!affixed) {
                // Means that it is even so must add a random digit in middle
                word = sb.append(word.substring(0, start + 1) + "x" + word.substring(start + 1, wordLen)).toString();
            } else if (affixed && (end - start == 1) && startChar != endChar) {
                return "NA";
            }

            return word;
        }

        if (affixed && startChar != endChar) {
            return "NA";
        }

        String result = "NA";

        if (startChar == endChar) {
            result = recurse(word, start + 1, end - 1, affixed);
        }

        if (!affixed && (result.equals("NA") || word.equals(result)) && startChar == word.charAt(end - 1)) {
            result = recurse(word.substring(0, start) + endChar + word.substring(start, wordLen),
                    start + 1, end, true);
        }

        if (!affixed && (result.equals("NA") || word.equals(result)) && word.charAt(start + 1) == endChar) {
            result = recurse(word.substring(0, end + 1) + startChar + word.substring(end + 1, wordLen),
                    start + 1, end, true);
        }

        return result;
    }
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main{
public static long mod = 1000000007;
public static int map[][];
public static int dx[] = {0,1,1,1,0,-1,-1,-1};
public static int dy[] = {-1,-1,0,1,1,1,0,-1};
public static void main(String args[]) throws IOException{
BufferedReader lector = new BufferedReader(new InputStreamReader(System.in));
String t = lector.readLine();
//StringBuilder sb = new StringBuilder("");
if(t.length()<2){System.out.println(t+t);return;}
for(int n = 0;n<=t.length();n++){
String tt = t.substring(0,n)+
((t.length())%2==0 && n==(t.length())/2?"a":t.charAt(t.length()-n-(n<t.length()/2?1:0)))+
(n<t.length()?t.substring(n):"");
boolean es = true;
//System.out.println("-->"+tt);
for(int m = 0;m<tt.length();m++)
if(tt.charAt(m)!=tt.charAt(tt.length()-1-m))es=false;
if(es){
System.out.println(tt);
return;
}
}

System.out.println("NA");
}
}

import java.util.*;

public class Main
{
	public static void main(String[] args)
	{

		// 451B 526A 439B
		Scanner s = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		sb.append(s.next());
		int len = sb.length();
		StringBuilder temp;

		for (int i = 0;i < len+1;i++)
		{
			for (char ch = 'a';ch <= 'z';ch++)
			{
				temp = new StringBuilder(12);
				temp.append(sb);
				if (isPalindrome(temp.insert(i, ch), len + 1))
				{
					System.out.println(temp);
					return;
				}

			}
		}

		System.out.println("NA");

	}

	public static boolean isPalindrome(StringBuilder sb, int len)
	{

		int half = len / 2;

		for (int i = 0;i < half;i++)
			if (sb.charAt(i) != sb.charAt(len - i - 1))
				return false;

		return true;
	}
}

import java.util.*;
public class Mod4 {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		String pattern = sc.nextLine();
		sb.append(pattern);
		int t = helper(sb,0);
		if(t == 1){
			sb = sb.reverse();
			helper(sb, 1);
		}
		sc.close();
	}
	public static int helper(StringBuilder sb, int time){
		int i=0, j = sb.length()-1;

		int unMatchPoint=0;
		char notMatch = '1';
		int misCounter = 0;
		while(i<=j){
			//reverse matching
			if(sb.charAt(i)== sb.charAt(j)){
				i++; j--;
				continue;
			}

			else if(sb.charAt(i)!= sb.charAt(j)){
				unMatchPoint = i;
				notMatch = sb.charAt(i);
				i++;
				misCounter++;
			}
		}
		if(misCounter>=2){
			time++;
			if(time>=2){
				System.out.println("NA");
			}
		} else{
			if(misCounter==0){
				int temp = sb.length()/2;
				sb.insert(temp , sb.charAt(temp));
				System.out.println(sb.toString());
			}
			if(misCounter == 1){
				sb.insert(sb.length()-unMatchPoint, notMatch);
				System.out.println(sb.toString());
			}
		}
		return time;
	}
}

import java.util.*;
public class MrKitayutaSGift {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int mean=0;
        int c=0;
        for(int i=0; i < s.length();i++){
        mean +=i;
        }
        for(int i=0; i < s.length();i++){
        if(s.length()%2==0){
            if(s.charAt(i)==s.charAt(s.length()-1-i)){c++;}

        }
        }
        if(c==s.length()/2){
             StringBuilder x;
            if(s.length()>1){
            x =p0(s).insert(mean/(p0(s).length()), s.charAt(1));}
            else {x =p0(s).insert(mean/(p0(s).length()), s.charAt(0));}
            System.out.println(x);
        }else
        if(rp(s).length()>0){System.out.println(rp(s));}else{
            System.out.println("NA");
        }

    }
    static StringBuilder p0(String s){
        int c=0;
        StringBuilder sb0 = new StringBuilder(s).reverse();
        for(int i=0;i<sb0.length();i++){
            if(sb0.charAt(i)==s.charAt(i)){
                c++;
            }
        }
        if(c==sb0.length()){
            return new StringBuilder(s);
        }else{
            return new StringBuilder();
        }
    }
    static boolean p(String s){
        int c=0;
        StringBuilder sb0 = new StringBuilder(s).reverse();
        for(int i=0;i<sb0.length();i++){
            if(sb0.charAt(i)==s.charAt(i)){
                c++;
            }
        }
        if(c==sb0.length()){
            return true;
        }else{
            return false;
        }
    }
    static StringBuilder rp(String s){
        String ns ="";
        StringBuilder sb = new StringBuilder(s);
        int count=0;
        //StringBuilder space =new StringBuilder("");

        //sb.insert(sb.length(), ' ');
        for(int i =s.length();i>=0;i--){
           for(char c='a';c<='z';c++){
           //space.append(c);
           sb.insert(i, c);
           ns=sb.toString();
           if(p(ns)){
                count++;
                break;
            }else{
               sb.deleteCharAt(i);
           }
           }
           if(p(ns)){

                break;
            }

        }
        if(count >0){
            return sb;
        }else{
            return new StringBuilder();
        }
    }

}

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.InputMismatchException;

public class testing {

    public static boolean palindrome(String s) {
        String v = s;
        v = new StringBuilder(v).reverse().toString();
        //System.out.println(v);
        return s.equals(v);
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
      OutputStream outputStream = System.out;
      InputReader in = new InputReader(inputStream);
      OutputWriter out = new OutputWriter(outputStream);

        String s = in.next();
        for(char c = 'a' ; c <= 'z' ; c++) {
            String v = "";
            v += c;
            v += s;
            if(palindrome(v)) {
                out.printLine(v);
                out.close();
                return;
            }
            v = s;
            v += c;
            //System.out.println(v);
            if(palindrome(v)) {
                out.printLine(v);
                out.close();
                return;
            }

            for (int i = 1, k = 0; i < s.length() - 1; i++) {
                v = s.substring(k, i);
                v += c;
                v += s.substring(i, s.length());
                if (palindrome(v)) {
                    out.printLine(v);
                    out.close();
                    return;
                }
            }
        }

        out.printLine("NA");
        out.close();
    }
}

class InputReader {
    private InputStream stream;
    private byte[] buffer = new byte[10000];
    private int cur;
    private int count;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public boolean isSpace(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public int read() {
        if (count == -1) {
            throw new InputMismatchException();
        }
        try {
            if (cur >= count) {
                cur = 0;
                count = stream.read(buffer);
                if (count <= 0)
                    return -1;
            }
        } catch (IOException e) {
            throw new InputMismatchException();
        }
        return buffer[cur++];
    }

    public int readSkipSpace() {
        int c;
        do {
            c = read();
        } while (isSpace(c));
        return c;
    }

    public int nextInt() {
        int sgn = 1;
        int c = readSkipSpace();
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res = res * 10 + c - '0';
            c = read();
        } while (!isSpace(c));
        res *= sgn;
        return res;
    }

    public String next() {
        int c = readSkipSpace();
        StringBuilder sb = new StringBuilder();
        while (!isSpace(c)) {
            sb.append((char) c);
            c = read();
        }
        return sb.toString();
    }
}

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0) {
                writer.print(' ');
            }
            writer.print(objects[i]);
        }
    }

    public void printLine(Object... objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }
}

import java.util.Scanner;

public class KitayutaGift {
	public static String voltear(String s){
		String k="";
		for (int i = s.length()-1; i >= 0 ; i--) {
			k+=s.charAt(i);
		}
		return k;
	}
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		String s2=s;
		int t=0;
		while(true){
			int j=s.length()-1,k=0;
			for (int i = 0; i < j; i++) {
				if(s.charAt(i)==s.charAt(j)){
					j--;
				}
				else{
					s=s.substring(0,j+1)+s.charAt(i)+s.substring(j+1,s.length());
					k++;
				}
				if(k>1)break;
			}
			if(k==1){
				System.out.println(s);break;
			}
			else{
				int n=s.length()/2;
				if(k==0){
					s=s.substring(0,n)+s.charAt(n)+s.substring(n,s.length());
					System.out.println(s);break;
				}
				else{
					s=voltear(s2);
				}
			}
			t++;
			if(t>=2){
				System.out.println("NA");break;
			}
		}

	}

}

import java.util.Scanner;
public class Helloworld
{
     public static void main(String[] args)
  {
      Scanner in = new Scanner(System.in);
      String word = in.next();
      System.out.println(solve(word));
  }

  public static String reverse(String w){
    String temp = "";
    for(int i = w.length() -1 ; i>=0;i--)temp+=w.charAt(i);
    return temp;
  }
  public static String solve(String w){

      String temp = "abcdefghijklmnopqrstuvwxyz";
      for(int i = 0 ; i < temp.length();i++)
      {
          for(int j = 0 ; j <= w.length();j++){
            String tem ="";
            tem+=(w.substring(0, j) + temp.charAt(i) + w.substring(j , w.length()));
            if(tem.equals(reverse(tem)))
                return tem;
          }
      }
      return "NA";
  }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class MakePalindrom {
    static String makeLetter(String s, int position) {
        String rs = "";
        List<Character> word = new ArrayList<Character>();
        for (char c : s.toCharArray())
            word.add(c);
        if (word.size() / 2 > position)
            word.add(word.size() - position, word.get(position));
        else
            word.add(word.size() - position - 1, word.get(position));
        for (Character c : word)
            rs += c;
        return rs;
    }

    static String deleteLetter(String s, int position) {
        String rs = "";
        List<Character> word = new ArrayList<Character>();
        for (char c : s.toCharArray())
            word.add(c);
        word.remove(position);
        for (Character c : word)
            rs += c;
        return rs;
    }

    static String putInMiddleLetter(String s) {
        String rs = "";
        List<Character> word = new ArrayList<Character>();
        for (char c : s.toCharArray())
            word.add(c);
        word.add(word.size() / 2, word.get(word.size() / 2));
        for (Character c : word)
            rs += c;
        return rs;
    }

    static boolean checkPalindrom(String s) {
        List<Character> word = new ArrayList<Character>();
        for (char c : s.toCharArray())
            word.add(c);
        int i = 0;
        int j = word.size() - 1;
        while (i < j) {
            if (word.get(i) != word.get(j))
                return false;
            i++;
            j--;
        }
        return true;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        String s = r.readLine();
        if (checkPalindrom(s))
            System.out.print(putInMiddleLetter(s));
        else {
            for (int i = 0; i < s.length(); ++i) {
                if (checkPalindrom(deleteLetter(s, i))) {
                    System.out.print(makeLetter(s, i));
                    return;
                }
            }
            System.out.print("NA");
        }
    }

}

/**
 * Created by kapilkrishnakumar on 9/8/15.
 */
import java.util.*;

public class CodeHW21 {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String word = sc.next();

        for(int i = 0; i <= word.length(); i++){
            for(int ch = 'a'; ch < 'z' + 1; ch++){
//                System.out.println(word +" pos"+i +" ch:"+ch);
                StringBuilder temp = new StringBuilder(word.substring(0,i));
                String cha = "" +(char)ch;
//                System.out.println(cha);
                temp.append(cha);
                temp.append(word.substring(i));
                String init = temp.toString();
                String reverse = temp.reverse().toString();
//                System.out.println(reverse);
                if(reverse.equals(init)){
                    System.out.println(temp.toString());
                    return;
                }

            }
        }
        System.out.println("NA");
    }
}

import java.io.IOException;
import java.util.Scanner;

public class jakb {

    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        StringBuffer s = new StringBuffer(str);
        if ((new StringBuilder(s)).reverse().toString().equals(str)) {
            if (s.length() % 2 == 0)
                System.out.println(s.substring(0, s.length() / 2) + "y" + s.substring(s.length() / 2));
            else
                System.out.println(s.substring(0, s.length() / 2) + s.charAt(s.length() / 2) + s.substring(s.length() / 2));
        } else {
            for (int i = 0; i <= s.length(); i++) {
                for (char ch = 'a'; ch <= 'z'; ch++) {
                    s.insert(i, ch);
                    if ((new StringBuilder(s)).reverse().toString().equals(s.toString())) {
                        System.out.println(s);
                        return;
                    }
                    s.deleteCharAt(i);
                }
            }
            System.out.println("NA");
        }

    }

}

import java.util.*;

public class KitayutaGift {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();

        if (isPalindrome(s)) {
            String str;
            if (s.length() % 2 == 0) {
                str = s.substring(0, s.length() / 2) + "a" + s.substring(s.length() / 2);
            }
            else {
                str = s.substring(0, (s.length() / 2) + 1) + s.charAt(s.length() / 2) + s.substring((s.length() / 2) + 1);
            }
            System.out.println(str);
        }
        else {
            if (foundPalindrome(s)) {
                sc.close();
            }
            else {
                System.out.println("NA");
                sc.close();
            }
        }
    }

    public static boolean isPalindrome(String str) {
        for(int i = 0; i < str.length() / 2; i++) {
            if (str.charAt(i) != str.charAt(str.length() - i - 1)) {
                return false;
            }
        }
        return true;
    }

    public static boolean foundPalindrome(String s) {
        for (int i = 0; i < s.length() + 1; i++) {
            for (char c = 'a'; c <= 'z'; c++) {
                String str = s.substring(0, i) + c + s.substring(i);
                if (isPalindrome(str)) {
                    System.out.println(str);
                    return true;
                }
            }
        }

        return false;
    }
}

import java.io.*;
import java.util.*;

public class A {
	public static void main(String[] args) throws IOException {
		Scanner s = new Scanner(System.in);
		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);

		StringBuilder bruteForce = new StringBuilder(f.readLine());
		String reverse = bruteForce.reverse().toString();
		bruteForce.reverse();
//		System.out.println(reverse + " " + bruteForce);
		if(bruteForce.toString().equals(reverse)) {
			if(bruteForce.length() % 2 == 0) {
				bruteForce.insert(bruteForce.length()/2, 'a');
			} else {
				char insert = bruteForce.charAt(bruteForce.length()/2);
				bruteForce.insert(bruteForce.length()/2, insert);
			}
			System.out.println(bruteForce);
			return;
		} else {
			int n = bruteForce.length();
			for(int i = 0; i <= n; i++) {
				for(int j = 'a'; j <= 'z'; j++) {
					StringBuilder newOne = new StringBuilder(bruteForce.toString());
					newOne.insert(i, (char)j);
					String rev = newOne.reverse().toString();
					newOne.reverse();
//					System.out.println(rev);
//					System.out.println(newOne);
					if(rev.equals(newOne.toString())) {
						System.out.println(newOne.toString());
						return;
					}
				}
			}
		}
		System.out.println("NA");
		out.close();
	}
}

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class MrKitayutaGift {

    static boolean palindrome(String w)
    {
        for (int i =0 ; i<w.length()/2;i++)
            if(w.charAt(i) != w.charAt(w.length()-i-1))
                return false ;
        return true ;
    }

    public static void main(String[] args)  throws Exception{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String word = in.readLine() ;
        char c ,c2 ;
        String word2 =word,end2 ;
        int l = word.length() ;
        int nb=0 ;
        String end ;
        for(int i = 0 ; i< (l/2) && nb < 1 ; i++ )
        {
            c = word.charAt(i) ;
            c2  = word.charAt( l - i -1 ) ;
            if(c != c2 )
            {
                end ="" ;
                end2 ="" ;
                if(i != 0)
                {
                    end= word.substring(l - i) ;
                    end2 = word.substring(0, i ) ;
                }
                word = word.substring(0,l - i) + c +end ;
                word2 = end2 + c2 + word2.substring(i);
                nb++ ;
            }
        }
        if(nb==0)
        {
            word = word.substring(0,(l/2)+1) + word.substring(l/2) ;
            System.out.println(word) ;
        }
        else if(palindrome(word))
        {
            System.out.println(word);
        }
        else if(palindrome(word2))
        {
            System.out.println(word2);
        }
         else
        {
            System.out.println("NA");
        }

    }

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class a286 {

	static class Task{

		public void solve(InputReader in, PrintWriter out)
		{
			String S=in.next();
			int n=S.length();

			int p=0;
			for(int i=0;i<(S.length()+1)/2;i++)
			{
				if(S.charAt(i)!=S.charAt(n-1-i))
				{
					p=1;
					break;
				}
			}
			if(p==0)
			{
				String s="";
				String s1="";
				String al="a";
				if(n%2!=0)
				{
					s=S.substring(0,n/2+1);
				    out.print(s);
				    for(int i=n/2;i>-1;i--)
				    {
				    	out.print(s.charAt(i));
				    }
				    return;
				}
				else
				{
					s=S.substring(0,n/2);
					s1=S.substring(0,n/2);
					s=s.concat(al);
					out.print(s);
					for(int i=n/2-1;i>-1;i--)
					{
					  	out.print(s1.charAt(i));
				    }
				//	out.println(s);
					return;
				}

			}
			else
			{
				String s1=S;
				String s2=S;
				for(int i=0;i<(n+1)/2;i++)
				{
					if(s1.charAt(i)!=s1.charAt(n-1-i))
					{
						String temp=Character.toString(s1.charAt(i));
						String t1=s1.substring(0,n-i);
						String t2=s1.substring(n-i,n);
						String t3=(t1.concat(temp)).concat(t2);
						String temp2=Character.toString(s1.charAt(n-1-i));
						String t12=s1.substring(0,i);
						String t22=s1.substring(i,n);
						String t32=(t12.concat(temp2)).concat(t22);
						if(ispalindrome(t3))
						{
							out.println(t3);
							return;
						}
						if(ispalindrome(t32))
						{
							out.println(t32);
							return;
						}
					}
				}
			}
			out.println("NA");

		}
	}

	public static boolean ispalindrome(String s)
	{
		boolean p=true;
		for(int i=0;i<(s.length()+1)/2;i++)
		{
			if(s.charAt(i)!=s.charAt(s.length()-1-i))
			{
				p=false;
				break;
			}
		}
		return p;
	}

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in,out);
        out.close();
    }

    static int[][] sort2D(int arr[][]){
        Arrays.sort(arr,new java.util.Comparator<int[]>(){
        public int compare(int[] a, int[] b) {
            return Integer.compare(a[0], b[0]);
        }});
        return arr;
    }

	static int[] di={1,0,-1,0,1,-1,-1,1};
	static int[] dj={0,1,0,-1,1,1,-1,-1};

	static class point{
		int x;int y;
		public point(int x,int y){
			this.x=x;
			this.y=y;
		}
	}

    static int abs(int x){if(x>=0)return x;else return -x;}
    static int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
    static int min(int x,int y){return x<y?x:y;}
    static int min(int x,int y,int z){return x<y?(x<z?x:z):(y<z?y:z);}
    static int max(int x,int y){return x>y?x:y;}
    static int max(int x,int y,int z){return x>y?(x>z?x:z):(y>z?y:z);}

    static long abs(long x){if(x>=0)return x;else return -x;}
    static long gcd(long a,long b){return b==0?a:gcd(b,a%b);}
    static long min(long x,long y){return x<y?x:y;}
    static long min(long x,long y,long z){return x<y?(x<z?x:z):(y<z?y:z);}
    static long max(long x,long y){return x>y?x:y;}
    static long max(long x,long y,long z){return x>y?(x>z?x:z):(y>z?y:z);}

    static void joutArray(int arr[]){
    	for(int i=0;i<arr.length;i++){
    		System.out.print(arr[i]+" ");
    	}
    }

    static void joutArray(int arr[][],int n,int m){
    	for(int i=0;i<n;i++){
    		for(int j=0;j<m;j++)
    		System.out.print(arr[i][j]+" ");
    		System.out.println();
    	}
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
			String fullLine=null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine=reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
        	return Long.parseLong(next());
        }

        public double nextDouble() {
        	return Double.parseDouble(next());
        }

        public int[] nextIntArray(int n) {
        	int arr[]=new int[n];
        	for(int i=0;i<n;i++)
        		arr[i]=nextInt();
        	return arr;
        }

        public char[] nextCharArray(){
        	char arr[]=next().toCharArray();
        	return arr;
        }

        public int[][] nextIntArray(int n,int m){
        	int arr[][]=new int[n][m];
        	for(int i=0;i<n;i++)
        		for(int j=0;j<m;j++)
        			arr[i][j]=nextInt();
        	return arr;
        }
     }

   }

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.LinkedList;

public class Main1 {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        StringBuilder in = new StringBuilder().append(br.readLine());

        int index = -1;
        int last = in.length() - 1;
        int start = 0;
        boolean flag = false;
        char c = 0;
        int[]character = new int[27];
//      System.out.println(Character.getNumericValue('b'));
        for(int i = 0;i<in.length();i++){
            character[in.charAt(i)-'a']++;
        }
        while (true) {
            if (in.charAt(start) != in.charAt(last)
                    && in.charAt(start + 1) == in.charAt(last) && (character[in.charAt(start)-'a']+1)%2==0) {
                if (index == -1) {
                    index = last +1;
                    c = in.charAt(start);
                    start++;
                } else {
                    flag = true;
                    break;
                }
            } else if (in.charAt(start) != in.charAt(last)
                    && in.charAt(start) == in.charAt(last - 1)&& (character[in.charAt(last)-'a']+1)%2==0) {
                if (index == -1) {
                    index = start;
                    c = in.charAt(last);
                    last--;
                } else {
                    flag = true;

                    break;
                }
            } else if (in.charAt(start) == in.charAt(last)) {
                start++;
                last--;
            } else {
                flag = true;

                break;
            }
            if (start >= last)
                break;
        }

        if (index == -1) {
            c = in.charAt(in.length() / 2);
            index = in.length() / 2;
        }
        if (flag)
            System.out.println("NA");
        else {

            System.out.println(in.insert(index, c));
        }

    }
}

import java.util.*;

public class Main
{
	public static void main(String[] args)
	{

		// 451B 526A 439B
		Scanner s = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		sb.append(s.next());
		int len = sb.length();
		StringBuilder temp;

		for (int i = 0;i < len+1;i++)
		{
			for (char ch = 'a';ch <= 'z';ch++)
			{
				temp = new StringBuilder(12);
				temp.append(sb);
				if (isPalindrome(temp.insert(i, ch), len + 1))
				{
					System.out.println(temp);
					return;
				}

			}
		}

		System.out.println("NA");

	}

	public static boolean isPalindrome(StringBuilder sb, int len)
	{

		int half = len / 2;

		for (int i = 0;i < half;i++)
			if (sb.charAt(i) != sb.charAt(len - i - 1))
				return false;

		return true;
	}
}

public class Kitayuta
{
     public static boolean pal(String s1){
         String s2 = new StringBuilder(s1).reverse().toString();

            if(s1.compareTo(s2)== 0){
                return true;
            }
            else{
                return false;
            }
    }

    public static void main(String args[])
    {
        String h = "kitayuta";
        String h1;
        boolean flag =false;
        char c;

        for (int i = h.length(); i >= args.length; i--)
        {
            for (int j = 0; j < 26; j++)
            {
                int x =97+j;
                c = (char) x;
                h1 = new StringBuilder(h).insert(i, c).toString();

                if(pal(h1)){
                    System.out.println(h1);
                    flag = true;
                    break;
                }
            }
            if(flag){break;}
        }
        if(!flag){System.out.println("NA");}
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Locale;
import java.util.Scanner;
import java.util.TreeSet;
import org.omg.CORBA.MARSHAL;

/**
 *
 * @author таня
 */
public class KF {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        B jk = new B();
    }
}

class B {

    PrintWriter out = new PrintWriter(System.out);
    Scanner in = new Scanner(System.in);
   String pr=in.next();
   String abc="qwertyuiopasdfghjklzxcvbnm";
  B(){
      for(int i=0;i<26;i++){
      String k = abc.substring(i,i+1)+pr;
  if(test(k)==true){
  out.print(k);
  out.flush();
  return;
  }
      }
         for(int i=0;i<26;i++){
      String k =pr+ abc.substring(i,i+1);
  if(test(k)==true){
  out.print(k);
  out.flush();
  return;
  }
      }
     for(int j=0;j<pr.length();j++){
  for(int i=0;i<26;i++){
  String k = pr.substring(0,j+1)+abc.substring(i,i+1)+pr.substring(j);
  if(test(k)==true){
  out.print(k);
  out.flush();
  return;
  }
  }
  }
     out.print("NA");
     out.flush();
  }
  boolean test(String s){
        char[] el = s.toCharArray();
      for(int i=0;i<=el.length/2;i++){
      if(el[i]!=el[el.length-i-1]){
      return false;
      }
      }
  return true;
  }
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class codeforces_a_505 {

    static class FastScanner{
        BufferedReader s;
        StringTokenizer st;

        public FastScanner(){
            st = new StringTokenizer("");
            s = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastScanner(File f) throws FileNotFoundException{
            st = new StringTokenizer("");
            s = new BufferedReader (new FileReader(f));
        }

        public int nextInt() throws IOException{
            if(st.hasMoreTokens())
                return Integer.parseInt(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextInt();
            }
        }

      public double nextDouble() throws IOException{
            if(st.hasMoreTokens())
                return Double.parseDouble(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextDouble();
            }
        }

        public long nextLong() throws IOException{
            if(st.hasMoreTokens())
                return Long.parseLong(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextLong();
            }
        }

        public String nextString() throws IOException{
            if(st.hasMoreTokens())
                return st.nextToken();
            else{
                st = new StringTokenizer(s.readLine());
                return nextString();
            }

        }
        public String readLine() throws IOException{
            return s.readLine();
        }

        public void close() throws IOException{
            s.close();
        }

    }
      private static FastScanner s = new FastScanner();
      private static PrintWriter ww = new PrintWriter(new OutputStreamWriter(System.out));

      static int count=0;
     public static void main(String[] args) throws IOException
     {
        String ss = s.nextString();
        StringBuffer sd = new  StringBuffer(ss);
        String rev = sd.reverse().toString();
        if(pal(ss))
        {
            if(ss.length()%2==0)
            {   System.out.println(""+ss.substring(0,ss.length()/2)+"y"+ss.substring(ss.length()/2,ss.length()));
            }
            else
            {
                  System.out.println("NA");
            }
        }
        else
        {
           String dg=mpal(ss);
            //System.out.println(""+dg);
           if(pal(dg))
           {
               System.out.println(""+dg);
           }
           else
           {
               System.out.println("NA");
           }
        }

         s.close();
         ww.close();
     }
     public static boolean pal(String a)
     {
        StringBuffer sr = new StringBuffer(a);
        String rev = sr.reverse().toString();
        if(rev.equals(a))
            return true;
        else
            return false;
     }

        public static String mpal(String ss)
     {
        StringBuffer sr = new StringBuffer(ss);String ans="art";
        StringBuilder sb=new StringBuilder(ss);
        String rev = sr.reverse().toString();boolean arc=true;
        if(rev.charAt(0)!=ss.charAt(0))
        {
           sb.setCharAt(0,rev.charAt(0));
           ans=sb.toString();
            if(!pal(ans))
            {
                sb=new StringBuilder(ss);
                sb.append(ss.charAt(0));
                ans=sb.toString();
            }

        }
        else
        {
          for(int i=0;i<ss.length();i++)
          {
              if(ss.charAt(i)!=rev.charAt(i))
              {
                  sb.setCharAt(i,rev.charAt(i));break;
              }
          }
            ans=sb.toString();

        }
        return ans;
     }
        public static int gcd(int a, int b){
        return b == 0 ? a : gcd(b,a%b);
    }

}
/*zabardast swappimng of sorting
/*
    for(int h=0;h<n;h++)
        {  int temp,temp1,temp2;
             for(int y=h+1;y<n;y++)
           {
             if(a[y][2]>=a[h][2])
             {

             temp=a[y][2];                 //////sorting
             a[y][2]=a[h][2];
              a[h][2]=temp;
              temp1=a[y][0];
              a[y][0]=a[h][0];
              a[h][0]=temp1;
              temp2=a[y][1];
              a[y][1]=a[h][1];
              a[h][1]=temp2;

             }
           }
        }
*/
/*
static final Point getMinMax(int[] array) {
        int min = array[0];
        int max = array[0];

        for (int index = 0, size = array.length; index < size; ++index, ++index) {
            int value = array[index];

            if (index == size - 1) {
                min = min(min, value);
                max = max(max, value);
            } else {
                int otherValue = array[index + 1];

                if (value <= otherValue) {
                    min = min(min, value);
                    max = max(max, otherValue);
                } else {
                    min = min(min, otherValue);
                    max = max(max, value);
                }
            }
        }

        return new Point(min, max);
    }

*/
/*

/// Demonstrate several Is... methods.
class IsDemo {
public static void main(String args[]) {
char a[] = {'a', 'b', '5', '?', 'A', ' '};
for(int i=0; i<a.length; i++) {
if(Character.isDigit(a[i]))                                   ///check if digit is present in string
System.out.println(a[i] + " is a digit.");
if(Character.isLetter(a[i]))
    System.out.println(num + " in binary: " +
Integer.toBinaryString(num));
System.out.println(num + " in octal: " +
Integer.toOctalString(num));
System.out.println(num + " in hexadecimal: " +
Integer.toHexString(num));
}
}
*/
/*
private static void findSubsets(int array[])
{
  int numOfSubsets = 1 << array.length;

  for(int i = 0; i < numOfSubsets; i++)
 {
    int pos = array.length - 1;                                /////bitmask to find all sub sets
   int bitmask = i;

   System.out.print("{");
   while(bitmask > 0)
   {
    if((bitmask & 1) == 1)
     System.out.print(array[pos]+",");
    bitmask >>= 1;
    pos--;
   }
   System.out.print("}");
 }
}
*/

/*   no of DIVISORSSSSSS
 public ArrayList<Integer> get(int x){
            ArrayList<Integer> divisors = new ArrayList<>();
            for(int i = 1; i * i <= x; i++){
                if(x % i == 0){
                    divisors.add(i);
                    if(i * i != x){
                        divisors.add( x / i);
                    }
                }
            }

*/
/*  //// find sum of multiple of a value below limit// ----> (l*(n+1))/2
  public static long getSequenceSum(long value, long limit) {
long q = (limit - 1) / value;
long ans = ((value*q)*(1+q) )/ 2;
return ans;
}
*/
/*// largest prime factor of a no
 public static long largestPrimeFactor(long n) {

        // largest composite factor must be smaller than sqrt
        long sqrt = (long)Math.ceil(Math.sqrt((double)n));

        long largest = -1;

        for(long i = 2; i <= sqrt; i++) {
            if(n % i == 0) {
                long test = largestPrimeFactor(n/i);
                if(test > largest) {
                    largest = test;
                }
            }
        }

        if(largest != -1) {
            return largest;
        }

        // number is prime
        return n;
    }
*/
/*    // prime no using sieve of erostheneses
  public static void prime()
{
  boolean[] isPrime = new boolean[100000000+ 1];
         Arrays.fill(isPrime, true);

        // mark non-primes <= N using Sieve of Eratosthenes
        for (int i = 2; i*i <= 100000000; i++)
        {

             if (isPrime[i])
             {
                for (int j = i; i*j <= 100000000; j++) {
                    isPrime[i*j] = false;
                }
            }
        }
}

*/

//package code;

import java.util.Scanner;

public class dab {

	public static boolean check(String s){

		StringBuilder temp=new StringBuilder(s).reverse();

		return temp.toString().equals(s);
	}

	public static void main(String args[]){

		Scanner in=new Scanner (System.in);
		String S=in.nextLine();
		String temp="";

		if(S.length()==1){
			System.out.println(S+S);
			return;
		}
		else if(check(S)&&S.length()%2!=0){
			System.out.println("NA");
			return;
		}
		else if (check(S)&&S.length()%2==0){
			S=S.substring(0, S.length()/2)+"a"+S.substring(S.length()/2);
			System.out.println(S);
			return;
		}
		else
		{
				for(int i=97;i<123;i++){
					temp=i+S;
					if(check(temp)){
						System.out.println(S);
						return ;
					}
				}

				for(int i=97;i<123;i++){
						temp=S+(char)i;
						if(check(temp)){
							System.out.println(temp);
							return ;
						}
				}

		}
		System.out.println("NA");

	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class A {
	public static boolean isPalindrome(String rez) {
		StringBuilder check = new StringBuilder();
		check.append(rez);
		if (rez.equals(check.reverse().toString())) {
			return true;
		}
		return false;
	}

	public static void main(String[] args) throws IOException {
		Reader.init(System.in);
		String line = Reader.next();
		int n = line.length();
		String rez = "";
		if (isPalindrome(line)) {
			rez = line.substring(0, n / 2) + line.charAt(n / 2) + line.substring(n / 2, n);
		} else {
			for (int i = 0; i < line.length() / 2; i++) {

				if (line.charAt(i) != line.charAt(n - 1 - i)) {
					rez = line.substring(0, n - i) + line.charAt(i) + line.substring(n - i, n);
					break;
				}
			}
		}
		if (isPalindrome(rez)) {
			System.out.println(rez);
		} else {
			System.out.println("NA");
		}
	}
}

class Reader {
	static BufferedReader reader;
	static StringTokenizer tokenizer;

	/** call this method to initialize reader for InputStream */
	static void init(InputStream input) {
		reader = new BufferedReader(new InputStreamReader(input));
		tokenizer = new StringTokenizer("");
	}

	/** get next word */
	static String next() throws IOException {
		while (!tokenizer.hasMoreTokens()) {
			// TODO add check for eof if necessary
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	static String nextLine() throws IOException {
		return reader.readLine();
	}

	static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}
}

import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        // Start writing your solution here. -------------------------------------

      /*
      int n      = sc.nextInt();        // read input as integer
      long k     = sc.nextLong();       // read input as long
      double d   = sc.nextDouble();     // read input as double
      String str = sc.next();           // read input as String
      String s   = sc.nextLine();       // read whole line as String

      int result = 3*n;
      out.println(result);                    // print via PrintWriter
      */

        String s = sc.next();
        String result = "NA";
        int tmpl = 0;
        char tmp = 'a';
        int l = s.length();
        //erre

        for (int i = 0; i < l; i++){
            tmp = s.charAt(i);
            for (int j = 0; j <= l; j++){

                if (!check(s.substring(0, j) + tmp + s.substring(j, l)).equals("NA")){
                    result =  check(s.substring(0, j) + tmp + s.substring(j, l));

                }

            }
        }

        System.out.println(result);

        // Stop writing your solution here. -------------------------------------

        out.close();
    }
//sds
    public static String reverse(String s){

        int l = s.length();
        String ss = "";

        for (int i = l-1; i >= 0 ; i--){
            ss += s.charAt(i);
        }

        return ss;
    }

    public static String check(String s){

        String result = "NA";

        int l = s.length();

        if (s.substring(0, l/2).equals(reverse(s.substring(l / 2, l))) ){
            result = s.substring(0, l/2) + "y" + s.substring(l/2, l);
        }

        if (s.substring(0, l/2).equals(reverse(s.substring(l / 2+1, l))) ){

            result = s.substring(0, l/2) + s.substring(l/2, l);
        }

        return result;
    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    //--------------------------------------------------------
}

import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        String[] a = { "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" };
        String[] tokens = s.split("");
        boolean tru = false;
        for (int i = 0; i <= tokens.length; i++) {
            for (int n = 0; n < a.length; n++) {
                StringBuffer test = new StringBuffer();
                for (int x = 0; x < tokens.length; x++) {

                    if (x == i) {

                        test.append(a[n]);
                    }
                    test.append(tokens[x]);
                    if(i == x + 1){
                        test.append(a[n]);
                    }
                }
                if(isPal(test.toString())){
                    System.out.println(test.toString());
                    tru = true;
                    break;
                }
            }
            if(tru){
                break;
            }

        }
        if(!tru){
            System.out.println("NA");
        }

    }

    public static boolean isPal(String s) {

        for (int i = 0; i < s.length() / 2; i++) {
            if (s.charAt(i) != s.charAt(s.length() - 1 - i))
                return false;
        }
        return true;
    }
}

import java.util.Scanner;
public class KitayutaSGift
{

    public static void main(String[] args)
    {
        Scanner in = new Scanner (System.in);
        String s = in.next();
        if (palindroom(s))
            System.out.println(s);

        else
        {
            StringBuilder test = new StringBuilder();
            test.append(s);
            int i=0;
            int j=0;
            char add='a';

            while(i<=test.length())
            {
                add='a';
                while (add<='z')
                {
                    test.insert(i, add);
                   if (palindroom(test))
                   {
                       System.out.println(test);
                       j++;
                       break;
                   }
                   else test.deleteCharAt(i);
                  add++;
                }
                i++;
                if (j>0)
                    break;
            }
            if (j==0)
                System.out.println("NA");

        }
    }
     public static boolean palindroom (String s)
    {
        int i=s.length();
        String palind="";
        while (i>0)
        {
            palind += s.substring(i-1,i);
            i--;
        }
        if (s.equals(palind))
            return true;
        else
            return false;
    }
      public static boolean palindroom (StringBuilder s)
    {
        int i=0;
        int j=s.length()-1;
        int count=0;
        while (i<s.length())
        {
            if (s.charAt(i)==s.charAt(j))
                count++;
            i++;
            j--;
        }

        if (count==s.length())
            return true;
        else
            return false;
    }

}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {
 public static boolean pal(String str){
     return str.equals(new StringBuilder(str).reverse().toString());
 }

 public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String x=in.nextLine();
    if(pal(x)){
     char A='a';
     String mine="";
     for(int i=0;i<x.length();i++){
         mine=x.substring(0,i+1)+A+x.substring(i+1,x.length());
         if(pal(mine))break;
     }
     if(pal(mine))System.out.println(mine);
     else System.out.println("NA");
 }
     else {
        char A;
     String mine="";
     for(int i=0;i<=x.length()/2;i++){
         A=x.charAt(i);
         mine=x.substring(0,x.length()-i)+A+x.substring(x.length()-i,x.length());
         if(pal(mine))break;
     }
     if(pal(mine))System.out.println(mine);
     else System.out.println("NA");
     }
   }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public String findPalindrome(String argument)
    {
        StringBuilder arg = new StringBuilder(argument);
        StringBuilder value = new StringBuilder(argument);
        arg = arg.reverse();
        int length = arg.length();
        boolean flag = false, found = false;
        for(int i = 0; i < length; i ++)
        {
            if(value.charAt(i) == arg.charAt(i))
            {
                if(i == length - 1)
                    found = true;
                continue;
            }
            else if(!flag)
            {
                arg.insert(i, value.charAt(i));
                value.insert(length - i, value.charAt(i));
                flag = true;
            }
            else
            {
                found = false;
            }
        }
        if(!flag)
        {
            if(length % 2 == 0)
                value.insert(length / 2, 'a');
            else
            {
                value.insert(0, "a");
                value.insert(length, "a");
            }
        }
        if(found)
            return value.toString();
        else
            return "NA";
    }
    public static void main(String[] args) throws IOException{
        Main main = new Main();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String argument;
        argument = br.readLine();
        br.close();
        String palindrome = main.findPalindrome(argument);
        System.out.println(palindrome);
    }
}

import java.util.*;
import java.math.*;
import java.io.*;

public class MakePalindrom{

	public static void main(String[] args) throws Exception{
		Scanner pm = new Scanner(System.in);
		int[] hash = new int[26];
		String s = pm.next();
		int k = s.length();
		StringBuffer sb = new StringBuffer(s);
		if(k == 1){
			System.out.println(sb.append(sb));
			return;
		}
		for(int i=0;i<k;i++) {
			int po = (int)s.charAt(i) - 97;
			hash[po]++;
			//int -> Integer.parseInt(br.readLine());
			/*int[] -> String str = br.readLine();
					   String[] astr = str.split(" ");
					   for(int i=0;i<n;i++)
				   	   arr[i] = Integer.parseInt(astr[i]);*/

		} //end of test case
		//int max = Arrays.stream(hash).max().orElse(0);
		int cnt = 0;
		ArrayList<Character> pos = new ArrayList<>();
		ArrayList<Character> pl = new ArrayList<>();
		for(int i=0;i<k;i++)
				pl.add(s.charAt(i));
		int a = 0;
		int nom = 0;
		int flag = 0;
		int ins = 0;
		int n = pl.size();
		int pt1 = 0;
		int pt2 = n-1;
		while(true){
			//System.out.println(pl.get(pt1)+" "+pl.get(pt2));
			if(pl.get(pt1) == pl.get(pt2) ){
				pt1++;
				pt2--;
				//continue;
			}
			else if(nom == 0) {

				nom = 1;
				pl.add(pt2+1,pl.get(a));
				ins = 1;
				pt1++;
			}
			else if(nom == 1) {
				flag = 1;
				break;
			}
			//a++;
			if(pt1 == pt2 - 1 || pt1 >= pt2)
				break;
			//System.out.println(pl);
		}
		//System.out.println(flag);
		if(ins == 0 && n % 2 == 0){
			pl.add(n/2,'a');
		}
		else if(ins == 0 && n % 2 == 1)
			flag = 1;
		if(flag == 1)
			System.out.println("NA");
		else{
			StringBuilder b = new StringBuilder();
   			pl.forEach(b::append);
   			System.out.println(b);
		}

	} //end of main()
} //end of class

import java.util.Scanner;
public class MrKitayutaSGift
{

    public static void main(String[] args)
    {
       Scanner in = new Scanner (System.in);
       String s = in.next();

       if (s.length()==1)
           System.out.println(s+s);
       else if (palindroom(s)&&s.length()%2==0)
       {
           System.out.println(s.subSequence(0, s.length()/2)+"a"+s.subSequence(0, s.length()/2));
       }
        else
       {

           int i=0;
           int j=0;
           int counter=0;
           int div = s.length()/2;
           String fristHalf = s.substring(0, div);
           String secHalf=s.substring(div+1);
           i=fristHalf.length()-1;
           while (j<secHalf.length())
           {
                if (fristHalf.charAt(i)==secHalf.charAt(j))
                 {
                    counter++;
                 }
                 j++;
                i--;
           }

           if (palindroom(s+s.charAt(0)))
               System.out.println(s+s.charAt(0));
           else if (palindroom(s.charAt(s.length()-1)+s))
               System.out.println(s.charAt(s.length()-1)+s);

           else
               System.out.println("NA");
       }

    }
    public static boolean palindroom (String s)
    {
        int i=s.length();
        String palind="";
        while (i>0)
        {
            palind += s.substring(i-1,i);
            i--;
        }
        if (s.equals(palind))
            return true;
        else
            return false;
    }

}

import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner (System.in);
		String s = input.nextLine();
		int low = 0 ;
		int afterlow =1;
		int high = s.length()-1;
		int beforehigh = s.length()-2;
		boolean bol = true ;int stage = -1;
		if(s.length()==1){
			System.out.println(s+s);System.exit(0);
		}
		else if(s.length()==2){
			if(s.charAt(0)==s.charAt(1)){
			System.out.println(s+s.charAt(0));
			}
			else if(s.charAt(0)!=s.charAt(1)){
				System.out.println(s+s.charAt(0));
			}
		}
		else if(s.length()>6&&s.charAt(0)!=s.charAt(high)&&s.charAt(1)!=s.charAt(high-1)){
				bol=false;
		}
		else if( s.charAt(low) == s.charAt(beforehigh)&&s.charAt(low+1) == s.charAt(beforehigh-1) ){
			stage = 3;
			String m = s.substring(0, s.length()-1);
			bol = ispalindrome(m);
		}
		else if(s.charAt(afterlow) == s.charAt(high)){
			stage =2;
			String m = s.substring(1, s.length());
			bol = ispalindrome(m);
		}
		else if (s.charAt(low) == s.charAt(high)){
			stage = 1;
			bol = ispalindrome(s);
		}

		else{
			bol=false;
		}

		if( bol == true && stage == 1){
			String s1=s.substring(0, s.length()/2);
			String s2 =s.substring(s.length()/2, s.length());
			System.out.println(s1+s.charAt(s.length()/2)+s2);
		}
		else if(bol == true && stage==2){
			System.out.println(s+s.charAt(0));
		}
		else if(bol==true&&stage==3){
			System.out.println(s.charAt(s.length()-1)+s);
		}
		else if (bol == false){
			System.out.println("NA");
		}
	}
		public static boolean ispalindrome(String z){
			int min = 0 ;
			int highh = z.length()-1;
			boolean bo=true;
			while(min<highh){
				if (z.charAt(min) != z.charAt(highh)){
					bo = false;break;
				}
				min++;highh--;
			}
			if(z.length()>2){
				int mi = min+1;
				if(z.charAt(mi) == z.charAt(highh)){
					String l = z.substring(0, (highh+1));
					String o = z.substring((highh+1), (z.length()));
					char c = z.charAt(min);
					z=l+c+o;
					bo = true ;
					System.out.println(z);System.exit(0);
				}
				int h = highh-1;
				if(z.charAt(min) == z.charAt(h)){
					String l = z.substring(0, (min));
					String o = z.substring((min), (z.length()));
					char c = z.charAt(highh);
					z=l+c+o;
					bo = true ;
					System.out.println(z);System.exit(0);
				}
			}
			return bo ;
		}
}

import java.io.*;

/**
 * Created by Domagoj on 18/01/15.
 */
public class KGift {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String in = br.readLine().trim();
            PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
            pw.println(solve(in));
            pw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static String solve(String str) {
        int size = str.length();
        int l = 0;
        int r = size - 1;
        while (l < r) {
            if (str.charAt(l) != str.charAt(r)) {
                break;
            }
            l++;
            r--;
        }
        if (l == r) {
            return str.substring(0, l + 1) + str.substring(l);
        }
        if (l > r) {
            return str.substring(0, l) + 'a' + str.substring(l);
        }
        String str1 = str.substring(0, r + 1) + str.charAt(l) + str.substring(r + 1);
        String str2 = str.substring(0, l) + str.charAt(r) + str.substring(l);
        boolean f1 = isPal(str1);
        boolean f2 = isPal(str2);
        if (f1) {
            return str1;
        } else if (f2) {
            return str2;
        }
        return "NA";
    }

    private static boolean isPal(String str) {
        int size = str.length();
        int ll = size / 2 - 1;
        for (int i = 0; i < ll; i++) {
            if (str.charAt(i) != str.charAt(size - i - 1)) {
                return false;
            }
        }
        return true;
    }
}

import java.util.Scanner;

/**
 * Created by chris on 2/3/2016.
 */
public class Solution {
    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        while(reader.hasNextLine()) {
            String s = reader.nextLine();
            System.out.println(pal(s));
        }
    }

    private static String pal(String s) {
        if(check(s)) {
            if(s.length() % 2 == 0) {
                return s.substring(0, s.length() / 2) + "a" + s.substring(s.length() / 2);
            }
            else {
                return s.substring(0, s.length() / 2 + 1) + s.substring(s.length() / 2);
            }
        }
        int start = 0;
        int end = s.length() - 1;
        while(start < end) {
            //System.out.printf("start is %d, end is %d\n", start, end);
            if(s.charAt(start) != s.charAt(end)) {
                String made = "";
                if(s.charAt(start + 1) == s.charAt(end)) {
                    made = s.substring(0, end + 1) + s.charAt(start);
                    if(end != s.length() - 1) {
                        made += s.substring(end + 1);
                    }
                }
                else if(s.charAt(start) == s.charAt(end - 1)) {
                    if(start == 0) {
                        made += "" + s.charAt(0);
                    }
                    made = s.substring(0, start) + s.charAt(end) + s.substring(start);
                }
                else {
                    return "NA";
                }
                if(check(made)) {
                    return made;
                }
                else {
                    return "NA";
                }
            }
            else {
                start++;
                end--;
            }
        }
        return "NA";
    }

    private static boolean check(String s) {
        int start = 0;
        int end = s.length() - 1;
        while(start < end) {
            if(s.charAt(start) != s.charAt(end)) {
                return false;
            }
            start++;
            end--;
        }
        return true;
    }
}

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.InputMismatchException;

public final class MrKitayutasGift
{
	private static InputReader reader;
	private static OutputWriter writer;

	public static void main(String[] args)
	{
		MrKitayutasGift gift = new MrKitayutasGift();

		reader = gift.new InputReader(System.in);
		writer = gift.new OutputWriter(System.out);

		getAttributes();

		writer.flush();

		reader.close();
		writer.close();
	}

	public static void getAttributes()
	{
		String s = reader.next();

		if (isPalindrome(s))
		{
			String answer = "";
			int length = s.length();

			for (int i = 0; i < length / 2; i++)
				answer += s.charAt(i);

			answer += s.charAt(length / 2);

			for (int i = length / 2; i < length; i++)
				answer += s.charAt(i);

			writer.println(answer);

			return;
		}

		String answer;
		int length, count, pos;
		boolean result;

		answer = "";
		length = s.length();
		count = 0;
		pos = 0;
		result = false;

		int i, j;

		i = 0;
		j = length - 1;

		while (s.charAt(i) == s.charAt(j) && i < length / 2)
		{
			// System.out.println("current i : " + i + ", j : " + j);

			i++;
			j--;
		}

		while (true && i < length / 2)
		{
			// System.out.println("current i : " + i + ", j : " + j + ", count : " + count);

			if (s.charAt(i) == s.charAt(j - 1))
			{
				// System.out.println("here");

				if (isPalindrome(s.substring(i, j)))
				{
					pos = i;

					// System.out.println("postiion is : " + pos);

					break;
				}
				else
				{
					writer.println("NA");

					return;
				}
			}
			else if (s.charAt(i + 1) == s.charAt(j))
			{
				// System.out.println("yo!!");

				if (isPalindrome(s.substring(i + 1, j + 1)))
				{
					pos = j;

					// System.out.println("position is : " + pos);

					break;
				}
				else
				{
					writer.println("NA");

					return;
				}
			}
			else if (s.charAt(i) != s.charAt(j))
				count++;

			if (count > 1)
				break;

			// System.out.println("leaving i : " + i + ", j : " + j + ", count : " + count);

			i++;
			j--;
		}

		// System.out.println("count : " + count + ", pos : " + pos);

		if (count <= 1)
			result = true;

		if (result == false)
			writer.println("NA");
		else
		{
			if (length % 2 != 0)
			{
				if (pos > length / 2)
				{
					if (s.charAt(length / 2) != s.charAt(length / 2 + 1))
						result = false;
				}
				else if (s.charAt(length / 2) != s.charAt(length / 2 - 1))
					result = false;
			}

			if (!result)
			{
				writer.println("NA");

				return;
			}

			if (pos < length / 2)
			{
				for (int k = 0; k < pos; k++)
					answer += s.charAt(k);

				answer += s.charAt(length - 1 - pos);

				for (int k = pos; k < length; k++)
					answer += s.charAt(k);
			}
			else
			{
				for (int k = 0; k <= pos; k++)
					answer += s.charAt(k);

				answer += s.charAt(length - 1 - pos);

				for (int k = pos + 1; k < length; k++)
					answer += s.charAt(k);
			}

			writer.println(answer);
		}
	}

	public static boolean isPalindrome(String s)
	{
		int length = s.length();

		for (int i = 0; i < length / 2; i++)
			if (s.charAt(i) != s.charAt(length - 1 - i))
				return false;

		return true;
	}

	class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int read()
		{
			if (numChars == -1)
				throw new InputMismatchException();

			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}

			return buf[curChar++];
		}

		public int nextInt()
		{
			int c = read();

			while (isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-')
			{
				sgn = -1;
				c = read();
			}

			int res = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();

				res *= 10;
				res += c & 15;

				c = read();
			} while (!isSpaceChar(c));

			return res * sgn;
		}

		public long nextLong()
		{
			int c = read();

			while (isSpaceChar(c))
				c = read();

			int sign = 1;

			if (c == '-')
			{
				sign = -1;

				c = read();
			}

			long result = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();

				result *= 10;
				result += c & 15;

				c = read();
			} while (!isSpaceChar(c));

			return result * sign;
		}

		public float nextFloat() // problematic
		{
			float result, div;
			byte c;

			result = 0;
			div = 1;
			c = (byte) read();

			while (c <= ' ')
				c = (byte) read();

			boolean isNegative = (c == '-');

			if (isNegative)
				c = (byte) read();

			do
			{
				result = result * 10 + c - '0';
			} while ((c = (byte) read()) >= '0' && c <= '9');

			if (c == '.')
				while ((c = (byte) read()) >= '0' && c <= '9')
					result += (c - '0') / (div *= 10);

			if (isNegative)
				return -result;

			return result;
		}

		public double nextDouble() // not completely accurate
		{
			double ret = 0, div = 1;
			byte c = (byte) read();

			while (c <= ' ')
				c = (byte) read();

			boolean neg = (c == '-');

			if (neg)
				c = (byte) read();

			do
			{
				ret = ret * 10 + c - '0';
			} while ((c = (byte) read()) >= '0' && c <= '9');

			if (c == '.')
				while ((c = (byte) read()) >= '0' && c <= '9')
					ret += (c - '0') / (div *= 10);

			if (neg)
				return -ret;

			return ret;
		}

		public String next()
		{
			int c = read();

			while (isSpaceChar(c))
				c = read();

			StringBuilder res = new StringBuilder();

			do
			{
				res.appendCodePoint(c);

				c = read();
			} while (!isSpaceChar(c));

			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public void close()
		{
			try
			{
				stream.close();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}

	}

	class OutputWriter
	{
		private PrintWriter writer;

		public OutputWriter(OutputStream stream)
		{
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
					stream)));
		}

		public OutputWriter(Writer writer)
		{
			this.writer = new PrintWriter(writer);
		}

		public void println(int x)
		{
			writer.println(x);
		}

		public void print(int x)
		{
			writer.print(x);
		}

		public void println(int array[], int size)
		{
			for (int i = 0; i < size; i++)
				println(array[i]);
		}

		public void print(int array[], int size)
		{
			for (int i = 0; i < size; i++)
				print(array[i] + " ");
		}

		public void println(long x)
		{
			writer.println(x);
		}

		public void print(long x)
		{
			writer.print(x);
		}

		public void println(long array[], int size)
		{
			for (int i = 0; i < size; i++)
				println(array[i]);
		}

		public void print(long array[], int size)
		{
			for (int i = 0; i < size; i++)
				print(array[i]);
		}

		public void println(float num)
		{
			writer.println(num);
		}

		public void print(float num)
		{
			writer.print(num);
		}

		public void println(double num)
		{
			writer.println(num);
		}

		public void print(double num)
		{
			writer.print(num);
		}

		public void println(String s)
		{
			writer.println(s);
		}

		public void print(String s)
		{
			writer.print(s);
		}

		public void println()
		{
			writer.println();
		}

		public void printSpace()
		{
			writer.print(" ");
		}

		public void flush()
		{
			writer.flush();
		}

		public void close()
		{
			writer.close();
		}

	}

}

/*
 *
 * reviive reviave
 */

import java.util.*;

/**
 *
 * @author Hartha
 */
public class MrKitayutaSGift {

    public static boolean pal(String word)
    {
        int length = word.length();
        for(int i = 0; i < length /2; i++)
            if(word.charAt(i) != word.charAt(length - 1 - i))
                return false;
        return true;
    }
    public static void main(String[] args) {
        Scanner sin = new Scanner(System.in);
        String word = sin.next();

        if(word.length() % 2 != 0 && pal(word))
        {
            System.out.println("NA");
            return;
        }

        for(int i = 0; i < word.length(); i++)
        {
            char ch = word.charAt(i);
            for(int j = 0; j < word.length(); j++)
                if(pal(word.substring(0, j) + ch + word.substring(j)))
                {
                    System.out.println(word.substring(0, j) + ch + word.substring(j));
                     return;
                }
            if(pal(word+ch))
            {
                System.out.println(word+ch);
                return;
            }

        }
        System.out.println("NA");
    }

}

import java.util.Scanner;
   public class insert{
   public static void main(String[]a){
      int w=0;
      int m=0;
      Scanner f=new Scanner(System.in);
      String s=f.next();
      int x=s.length();
      char[]c=new char[x+1];
      for(int i=0;i<x;i++){
          c[i]=s.charAt(i);
      }
      if(x%2==0){
           m=x/2;
           for(int i=0;i<m;i++){
               for(int j=m;j<x;j++){
                   if(s.charAt(i)==s.charAt(j)){
                         w++;
                         break;
                   }
               }
           }
           if(w==(m-1)){
              for(int i=0,n=x;i<m;i++,n--){
                  c[n]=c[i];
              }
               for(int i=0;i<(x+1);i++){
	           System.out.print(c[i]);
              }
          }
           if(w==m){
             for(int i=0,n=x;i<m;i++,n--){
	          c[n]=c[i];
             }
             c[m]='a';
             for(int i=0;i<(x+1);i++){
               System.out.print(c[i]);
             }
          }
          if(w<(m-1)){
             System.out.print("NA");
          }
      }else{
		  m=x/2;
		    for(int i=0;i<m;i++){
		        for(int j=m;j<x;j++){
		            if(s.charAt(i)==s.charAt(j)){
		                w++;
		                break;
		            }
		       }
            }
		  if(w==m){
			 for(int i=0,n=x;i<m;i++,n--){
				          c[n]=c[i];
             }
		  }else{
			 System.out.print("NA");
		  }

	  }

   }
 }

import java.util.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		String s = new String();
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()){
			s = cin.next();
			int len = s.length();
			int res = -1;
			for(int i = 0 ; i < len ; i ++){
				int l = 0 ,r = len - 1;
				int tres = 1;
				while(l <= r){
					if(l == i){
						l ++;
						continue;
					}
					if(r == i){
						r --;
						continue;
					}
					if(s.charAt(l) != s.charAt(r)) tres = 0;
					l ++;r --;
				}
				if(tres == 1) res = i;
				if(res != -1) break;
			}
			if(res == -1) System.out.println("NA");
			else{
				if(res < len / 2){
					for(int i = 0 ; i < (len + 1) / 2 ; i ++)
						System.out.print(s.charAt(i));
					if(len % 2 == 0) System.out.print(s.charAt(len / 2));
					for(int i = (len + 1) / 2 - 1 ; i >= 0 ; i --)
						System.out.print(s.charAt(i));
					System.out.println();
				}
				else{
					for(int i = 0 ; i < (len + 1) / 2 ; i ++)
						System.out.print(s.charAt(len - 1 - i));
					if(len % 2 == 0) System.out.print(s.charAt(len / 2));
					for(int i = (len + 1) / 2 - 1 ; i >= 0 ; i --)
						System.out.print(s.charAt(len - 1 - i));
					System.out.println();
				}
			}
		}
	}
}

import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}
}

class Task {
	public void solve(int testNumber, InputReader in, PrintWriter out) {
		String str = in.next();
		int len = str.length();
		for(int i=0; i<len/2; ++i) {
			if(str.charAt(i)==str.charAt(len-i-1)) {
				continue;
			} else {
				String a = str.substring(0, i);
				String a1 = str.substring(0, len-i);
				String b = str.substring(i, len);
				String b1 = str.substring(len-i, len);
				String str1 = a + str.charAt(len-i-1) + b;
				String str2 = a1 + str.charAt(i) + b1;
				if( can(str1) ) {
					out.println(str1);
					break;
				}
				if( can(str2) ) {
					out.println(str2);
					break;
				}
				out.println("NA");
				break;
			}
		}
		if((len & 1) == 1) {
			out.println(str.substring(0,len/2)+str.charAt(len/2)+str.substring(len/2,len));
		} else {
			out.println(str.substring(0,len/2)+"a"+str.substring(len/2,len));
		}
	}
	Boolean can(String s) {
		int len = s.length();
		for(int i=0; i<len/2; ++i) {
			if(s.charAt(i)!=s.charAt(len-i-1)) {
				return false;
			}
		}
		return true;
	}
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

}

import java.util.Scanner;

/**
 *
 * @author Marwan
 */
public class Kitayuta {
     public static void main(String[] args)  {
    Scanner in = new Scanner(System.in);
    String s = in.next();
    if(s.length()==1) {
       System.out.println(s);
      System.exit(0);
    }
    for(int i=0; i<=s.length();i++) {
      for(char j='a'; j<='z'; j++){
          StringBuilder t= new StringBuilder(s.substring(0, i)+j+s.substring(i));

          if(t.toString().equals(t.reverse().toString())){
               System.out.println(t);
                    System.exit(0);
          }
      }
    }

         System.out.println("NA");
     }
}

import java.security.PublicKey;
import java.util.Scanner;

public class problem1
{
	public static void main(String[] args)
	{
		String s;
		Scanner scanner=new Scanner(System.in);
		s=scanner.nextLine();
		boolean flag=false;
		for(int i=0;i<s.length();i++)
		{
			if(flag)
				break;
			String str;
			for(int j=0;j<=s.length();j++)
			{
				str=s.substring(0,j)+s.charAt(i)+s.substring(j,s.length());
				if(judget(str))
				{
					System.out.println(str);
					flag=true;
				}
			}
		}
		if(!flag)
			System.out.println("NA");
	}
	public static boolean judget(String s)
	{
		for(int i=0;i<s.length();i++)
			if(s.charAt(i)!=s.charAt(s.length()-1-i))
				return false;
		return true;
	}
}

import java.io.*;
import java.util.*;

public class Main {
    static boolean isPalindorme(String s){
        int limit = s.length();
        if(limit%2 == 0) limit/=2;
        else limit = (s.length()-1) / 2;
        for(int i=0 ; i<=limit ; i++){
            if(s.charAt(i)!=s.charAt(s.length()-i-1)) return false;
        }
        return true;
    }

    public static void main(String[] args) throws Exception{
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String s = bf.readLine();
        boolean ans = false;
        int limit = s.length();
        if(limit%2 == 0) limit/=2;
        else limit = (s.length()-1) / 2;
        for(int i=0 ; i<limit ; i++){
            if(s.charAt(i)!=s.charAt(s.length()-i-1)){
                StringBuilder sb = new StringBuilder(s.substring(0, s.length()-i));
                sb.append(s.charAt(i));
                sb.append(s.substring(s.length()-i, s.length()));
                s=sb.toString();
                ans = true;
                break;
            }
        }
        if(!ans){
            if(s.length()%2==1) {
                StringBuilder sb = new StringBuilder(s.substring(0, limit));
                sb.append(s.charAt(limit));
                sb.append(s.substring(limit, s.length()));
                s=sb.toString();

            }
            else{
                StringBuilder sb = new StringBuilder(s.substring(0, limit));
                sb.append('a');
                sb.append(s.substring(limit, s.length()));
                s=sb.toString();
            }
        }
        if(isPalindorme(s)) System.out.println(s);
        else System.out.println("NA");

    }
}

import java.io.*;
import java.util.*;
public class A286 {
    public static void main(String[] args)throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String s=br.readLine();
        boolean flag=true;
        for(char ch='a';ch<='z';ch++)
        {String df=String.valueOf(ch)+s;
        if(palin(df))
        {flag=false;
            //System.out.println(df);
            break;
        }
            for(int i=0;i<s.length();i++)
            {
                String sd=s.substring(0,i+1)+String.valueOf(ch)+s.substring(i+1,s.length());
                //System.out.println(sd);
                if(palin(sd))
                {
                    flag=false;
                    System.out.println(sd);
                    break;
                }
            }
            if(flag==false)
            {
                break;
            }
        }
        if(flag==false)
        {

        }
        else
        {
            System.out.println("NA");
        }
    }
    public static boolean palin(String s)
    {
        boolean flag=true;int i=0,j=s.length()-1;
        while(i<j)
        {
           if(s.charAt(i++)==s.charAt(j--))
           {

           }
           else
           {
               flag=false;
               break;
           }
        }
        return flag != false;
    }

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vikash Kumar
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        Codeforces solver = new Codeforces();
        solver.solve(1, in, out);
        out.close();
    }

    static class Codeforces {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            String s = in.n();
            int len = s.length();
            for (int i = 0; i < len / 2; i++) {
                if (s.charAt(i) != s.charAt(len - 1 - i)) {
                    //out.println(s.charAt(i));
                    s = s.substring(0, len - i) + s.charAt(i) + s.substring(len - i, len);
                    break;
                }
            }
            if (s.length() == len) {
                s = s.substring(0, len / 2) + "a" + s.substring(len / 2, len);
            }
            boolean flag = true;
            for (int i = 0; i < s.length() / 2; i++) {
                if (s.charAt(i) != s.charAt(s.length() - i - 1)) {
                    flag = false;
                    break;
                }
            }
            out.println(flag ? s : "NA");
            //out.println(s);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
        }

        public String n() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                }
            }
            return st.nextToken();
        }

    }
}

import java.io.IOException;

/**
 * Created by kaaveh on 1/22/15.
 */

/*                        _
* _._ _..._ .-',     _.._(`))
*'-. `     '  /-._.-'    ',/
*   )         \            '.
*  / _    _    |             \
* |  a    a    /              |
* \   .-.                     ;
*  '-('' ).-'       ,'       ;
*     '-;           |      .'
*        \           \    /
*        | 7  .__  _.-\   \
*        | |  |  ``/  /`  /
*       /,_|  |   /,_/   /
*          /,_/      '`-'
*/

public class _505A_ {
    public static void main(String[] args) {   //I hope enjoy! :)

        kaaveh in = new kaaveh();
        String data = in.kLine(10);

        int size = data.length() / 2;
        int lng= data.length();
        String res = "";
        boolean palin = true;

        for (int i=0; i<size; i++){
            if (data.charAt(i) != data.charAt(lng-1-i)){
                res += data.substring(0,lng-i);
                res += data.charAt(i);
                res += data.substring(lng - i, lng);
                break;
            }
        }

        if (res.equals("")){
            if (lng % 2 == 0){
                System.out.println(data.substring(0, size) + "a" + data.substring(size, lng));
            }else {
                System.out.println(data.substring(0, size) + data.charAt(size) + data.substring(size, lng));
            }
            System.exit(0);
        }

        for (int i=0; i<size; i++){
            if (res.charAt(i) != res.charAt(lng-i)){
                palin = false;
            }
        }
        if (palin)
            System.out.println(res);
        else
            System.out.println("NA");
    }
}

class kaaveh{
    static String kLine (int maxLg)
    {
        byte lin[] = new byte [maxLg];
        int lg = 0, car = -1;
        String line = "";

        try
        {
            while (lg < maxLg)
            {
                car = System.in.read();
                if ((car < 0) || (car == '\n')) break;
                lin [lg++] += car;
            }
        }
        catch (IOException e)
        {
            return (null);
        }

        if ((car < 0) && (lg == 0)) return (null);  // eof
        return (new String (lin, 0, lg));
    }

    static String knex (int maxLg)
    {
        byte lin[] = new byte [maxLg];
        int lg = 0, car = -1;
        String line = "";

        try
        {

            while ((car < 0) || (car == '\n') || (car == ' ') || (car == '\t') || (car == '\r'))
                car = System.in.read();

            while (lg < maxLg)
            {
                if ((car < 0) || (car == '\n') || (car == ' ') || (car == '\t') || (car == '\r')) break;
                lin [lg++] += car;
                car = System.in.read();
            }
        }
        catch (IOException e)
        {
            return (null);
        }

        if ((car < 0) && (lg == 0)) return (null);  // eof
        return (new String (lin, 0, lg));
    }

    static int kint()
    {
        return Integer.parseInt(knex(11));
    }

    static long kLong()
    {
        return Long.parseLong(knex(20));
    }

    static double kdouble()
    {
        return Double.parseDouble(knex(100));
    }
}

import java.util.Scanner;

/**
 * Created by Jeremy on 1/31/2016.
 */
public class Gift {

    public static final String NA = "NA";

    public static String checkIfPossible(String word, int moveLeft, int moveRight) {

        int length = word.length();
        int halfway = length / 2;
        int indexToReplace = -1;
        char charToAdd = '0';
        boolean mismatchFound = false;
        int leftSide;
        int rightSide;

        leftSide = halfway - moveLeft;
        rightSide = halfway + moveRight;

        String result = null;

        while (leftSide >= 0 && rightSide < length) {
            char leftChar = word.charAt(leftSide);
            char rightChar = word.charAt(rightSide);

            if (leftChar != rightChar) {
                if (mismatchFound) {
                    return null;
                }

                mismatchFound = true;

                boolean replacementFound = false;

                if (leftSide - 1 >= 0) {
                    if (word.charAt(leftSide - 1) == rightChar) {
                        indexToReplace = rightSide;
                        charToAdd = leftChar;
                        replacementFound = true;
                        --leftSide;
                    }
                }

                if (rightSide + 1 < length) {
                    if (leftChar == word.charAt(rightSide + 1)) {
                        indexToReplace = leftSide;
                        charToAdd = rightChar;
                        replacementFound = true;
                        ++rightSide;
                    }
                }

                if (!replacementFound) {
                    return null;
                }
            }
            --leftSide;
            ++rightSide;
        }

        if (rightSide < length - 1 || leftSide > 0) {
            return null;
        }

        // Check if there is a one mismatch
        if (mismatchFound) {
            if( indexToReplace == 0)
                ++indexToReplace;
            result = word.substring(0, indexToReplace) + charToAdd + word.substring(indexToReplace, length);
        }
        else {
            if (rightSide == length && leftSide == 0) {
                result = word.substring(0, length) + word.charAt(0);
            }
            else {
                result = word.charAt(length - 1) + word.substring(0, length);
            }
        }

        return result;
    }

    public static String alreadyPalidrome(String word) {
        String result = null;
        int length = word.length();
        int rightSide;
        int leftSide;
        if(length % 2 == 0) {
            leftSide = length / 2 - 1;
            rightSide = length / 2;
        }
        else {
            leftSide = length / 2 - 1;
            rightSide = length / 2 + 1;
        }

        if(length == 1) {
            result = word.charAt(0) + "" + word.charAt(0);
            return result;
        }

        while (leftSide >= 0 && rightSide < length) {
            if(word.charAt(leftSide) != word.charAt(rightSide)) {
                return null;
            }
            --leftSide;
            ++rightSide;
        }

        if(length % 2 == 0) {
            result = word.substring(0, length / 2) + "a" + word.substring(length / 2, length);
        }
        else {
            result = word.substring(0, length / 2 + 1) + word.substring(length / 2, length);
        }
        return result;
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNextLine()) {
            String word = scan.nextLine();
            String result = alreadyPalidrome(word);
            if (word.length() % 2 == 0) {
                if (result == null) {
                    result = checkIfPossible(word, 1, 1);
                }
                if (result == null) {
                    result = checkIfPossible(word, 2, 0);
                }
            }
            else {
                if (result == null) {
                    result = checkIfPossible(word, 1, 0);
                }
                if (result == null) {
                    result = checkIfPossible(word, 0, 1);
                }
            }
            if (result == null) {
                result = NA;
            }
            System.out.println(result);
        }
    }
}

import java.util.Scanner;
public class a {
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    String str=sc.next();
    int l=str.length();
    boolean done=false;
    if(ispal(str)&&l%2!=0) {
      System.out.println(str);
      done=true;
    }
    else {
      for(int i=0;i<l;i++) {
        if(ispal(str.substring(0,i)+str.charAt(l-1-i)+str.substring(i))&&i!=l-1) {
          System.out.println(str.substring(0,i)+str.charAt(l-1-i)+str.substring(i));
          done=true;
          break;
        }
        else if(i==l-1&&ispal(str+str.charAt(0))) {
          System.out.println(str+str.charAt(0));
          done=true;
          break;
        }
      }
    }
    if(!done)
      System.out.println("NA");
  }
  public static boolean ispal(String s) {
    for(int i=0,j=s.length()-1;i<=j;i++,j--)
      if(!(s.charAt(i)+"").equals(s.charAt(j)+""))
      return false;
    return true;
  }
}

import java.util.*;
import java.io.*;

public class gift {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		char[] input = in.nextLine().toCharArray();
		ArrayList<Character> chars = new ArrayList<>();
		for(char c: input) {
			chars.add(c);
		}
		boolean done = false;
		loop:
		for(int i = 0; i <= chars.size(); i++) {
			for(char c = 'a'; c <= 'z'; c++) {
				chars.add(i, c);
				System.out.println(chars);
				if(isPal(chars)) {
					System.out.println("entered");
					done = true;
					for(char letter: chars) {
						System.out.print(letter);
					}
					System.out.println();
					break loop;
				}
				chars.remove(i);
			}
		}
		if(!done) {
			System.out.println("NA");
		}
	}

	public static boolean isPal(ArrayList<Character> chars) {
		for(int i = 0; i <= chars.size() / 2; i++) {
			if(chars.get(i) != chars.get(chars.size() - i - 1)) {
				return false;
			}
		}
		return true;
	}
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

// http://codeforces.com/problemset/problem/505/A

public class Kitayuta {

	public static void main(String[] arg) {
		Scanner input = new Scanner(System.in);
		String word = input.nextLine();
		System.out.println(Kitayuta(word));
	}

	public static boolean isPalindrome(String input) {
		int length = input.length();
		int limit = length / 2;
		int endCharStart = length - 1;
		for (int i = 0; i < limit; i++) {
			char firstChar = input.charAt(i);
			char secondChar = input.charAt(endCharStart - i);
			if (firstChar != secondChar) {
				return false;
			}

		}
		return true;
	}

	public static String Kitayuta(String input) {
		int length = input.length();
		if (isPalindrome(input)) {
			return alreadyPalindrome(input);
		}
		else {
			return notPalindrome(input);
		}
	}

	public static String alreadyPalindrome(String input) {
		int length = input.length();
		int halfPos = length / 2;
		if (length % 2 == 0) {
			String firstHalf = input.substring(0, halfPos);
			String secondHalf = input.substring(halfPos);
			return firstHalf + "a" + secondHalf;
		}
		else {
			char middleChar = input.charAt(halfPos);
			String firstHalf = input.substring(0, halfPos + 1);
			String secondHalf = input.substring(halfPos + 1);
			return firstHalf + middleChar + secondHalf;
		}
	}

	public static String notPalindrome(String input) {
		boolean[] existingChars = getChars(input);
		ArrayList<Character> charArrs = charArrays(existingChars);
		int lengthOfArrs = charArrs.size();
		for (int pos = 0; pos < input.length(); pos++) {
			for (int charPos = 0; charPos < lengthOfArrs; charPos++) {
				char currentChar = charArrs.get(charPos);
				String updated = insertChar(input, pos, currentChar);
				if (isPalindrome(updated)) {
					return updated;
				}
			}
		}
		return "N/A";
	}

	public static String insertChar(String input, int pos, char character) {
		int length = input.length();
		String firstHalf = input.substring(0, pos);
		String secondHalf = input.substring(pos);
		return firstHalf + character + secondHalf;
	}
	/*
	 * creates a boolean array, sets characters that exit to true.
	 */
	public static boolean[] getChars(String input) {
		boolean[] chars = new boolean[26];
		for (int i = 0; i < input.length(); i++) {
			char currentChar = input.charAt(i);
			int posInArray = currentChar - 'a';
			chars[posInArray] = true;
		}
		return chars;
	}

	/*
	 * Goes through the boolean of chars, then adds the chars to an ArrayList of chars.
	 */
	public static ArrayList<Character> charArrays(boolean[] chars) {
		ArrayList<Character> charArr = new ArrayList<Character>();
		for (int i = 0; i < chars.length; i++) {
			if (chars[i] == true) {
				char convertedChar = (char) ('a' + i);
				charArr.add(convertedChar);
			}
		}
		return charArr;

	}
}

import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner (System.in);
		String s = input.nextLine();
		int low = 0 ;
		int afterlow =1;
		int high = s.length()-1;
		int beforehigh = s.length()-2;
		boolean bol = true ;int stage = -1;
		if(s.length()==1){
			System.out.println(s+s);System.exit(0);
		}
		else if(s.length()==2){
			if(s.charAt(0)==s.charAt(1)){
			System.out.println(s+s.charAt(0));
			}
			else if(s.charAt(0)!=s.charAt(1)){
				System.out.println(s+s.charAt(0));
			}
		}
		else if(s.length()>6){
			if(s.charAt(0)!=s.charAt(high)&&s.charAt(1)!=s.charAt(high-1))
				bol=false;
		}
		else if( s.charAt(low) == s.charAt(beforehigh)&&s.charAt(low+1) == s.charAt(beforehigh-1) ){
			stage = 3;
			String m = s.substring(0, s.length()-1);
			bol = ispalindrome(m);
		}
		else if(s.charAt(afterlow) == s.charAt(high)){
			stage =2;
			String m = s.substring(1, s.length());
			bol = ispalindrome(m);
		}
		else if (s.charAt(low) == s.charAt(high)){
			stage = 1;
			bol = ispalindrome(s);
		}

		else{
			bol=false;
		}

		if( bol == true && stage == 1){
			String s1=s.substring(0, s.length()/2);
			String s2 =s.substring(s.length()/2, s.length());
			System.out.println(s1+s.charAt(s.length()/2)+s2);
		}
		else if(bol == true && stage==2){
			System.out.println(s+s.charAt(0));
		}
		else if(bol==true&&stage==3){
			System.out.println(s.charAt(s.length()-1)+s);
		}
		else if (bol == false){
			System.out.println("NA");
		}
	}
		public static boolean ispalindrome(String z){
			int min = 0 ;
			int highh = z.length()-1;
			boolean bo=true;
			while(min<highh){
				if (z.charAt(min) != z.charAt(highh)){
					bo = false;break;
				}
				min++;highh--;
			}
			if(z.length()>2){
				int mi = min+1;
				if(z.charAt(mi) == z.charAt(highh)){
					String l = z.substring(0, (highh+1));
					String o = z.substring((highh+1), (z.length()));
					char c = z.charAt(min);
					z=l+c+o;
					bo = true ;
					System.out.println(z);System.exit(0);
				}
				int h = highh-1;
				if(z.charAt(min) == z.charAt(h)){
					String l = z.substring(0, (min));
					String o = z.substring((min), (z.length()));
					char c = z.charAt(highh);
					z=l+c+o;
					bo = true ;
					System.out.println(z);System.exit(0);
				}
			}
			return bo ;
		}
}

        import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.text.DecimalFormat;
    import java.util.Arrays;
    import java.util.Scanner;

                  public class Codeforce{

                     public static void main(String[]args) throws IOException {
                            BufferedReader br = new BufferedReader (new InputStreamReader(System.in));

                             Scanner s=new Scanner(System.in);
                             String n=s.next();
                             int i=0;
                             int j=n.length()-1;
                             int le=n.length();
                             int count=0;
                             if(s(n).equals(n)){
                                 if(le%2==0){
                                     n=n.substring(0, le/2)+'a'+n.substring(le/2,le);
                                 }
                                 else
                                     n=n.substring(0,le/2+1)+n.charAt(le/2)+n.substring(le/2+1,le);
                                 System.out.println(n);
                             }
                             else{
                             while(i<j){

                                 if(n.charAt(i)!=n.charAt(j)){
                                     if(n.charAt(i+1)==n.charAt(j)){
                                        n=n.substring(0,j+1)+n.charAt(i)+n.substring(j+1,le);
                                         if(s(n).equals(n)){
                                             count++;
                                             break;
                                         }
                                         else{
                                             count=-1;
                                             break;
                                         }
                                     }

                                        else if(n.charAt(i)==n.charAt(j-1)){
                                            n=n.substring(0,i)+n.charAt(j)+n.substring(i,le);

                                            if(s(n).equals(n)){
                                                 count++;
                                                 break;
                                            }
                                             else{
                                                 count=-1;
                                                 break;
                                             }
                                        }
                                            else{
                                                count=-1;
                                                break;
                                            }

                                 }
                                 i++;
                                 j--;
                             }
                             if(count!=1)
                                 System.out.println("NA");
                             else
                                 System.out.println(n);
                             }

                     }
                     public static String s(String n){
                         String rev="";
                         for(int i=n.length()-1;i>=0;i--){
                             rev=rev+n.charAt(i);
                         }
                         return rev;
                     }
        }

import java.io.*;

/**
 * Created by Domagoj on 18/01/15.
 */
public class KGift {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String in = br.readLine().trim();
            PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
            pw.println(solve(in));
            pw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static String solve(String str) {
        int size = str.length();
        int l = 0;
        int r = size - 1;
        while (l < r) {
            if (str.charAt(l) != str.charAt(r)) {
                break;
            }
            l++;
            r--;
        }
        if (l == r) {
            return str.substring(0, l + 1) + str.substring(l);
        }
        if (l > r) {
            return str.substring(0, l) + 'a' + str.substring(l);
        }
        String str1 = str.substring(0, r + 1) + str.charAt(l) + str.substring(r + 1);
        String str2 = str.substring(0, l) + str.charAt(r) + str.substring(l);
        boolean f1 = isPal(str1);
        boolean f2 = isPal(str2);
        if (f1) {
            return str1;
        } else if (f2) {
            return str2;
        }
        return "NA";
    }

    private static boolean isPal(String str) {
        int size = str.length();
        int ll = size / 2 - 1;
        for (int i = 0; i < ll; i++) {
            if (str.charAt(i) != str.charAt(size - i - 1)) {
                return false;
            }
        }
        return true;
    }
}

import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        String[] a = { "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" };
        String[] tokens = s.split("");
        boolean tru = false;
        for (int i = 0; i <= tokens.length; i++) {
            for (int n = 0; n < a.length; n++) {
                StringBuffer test = new StringBuffer();
                for (int x = 0; x < tokens.length; x++) {

                    if (x == i) {

                        test.append(a[n]);
                    }
                    test.append(tokens[x]);
                    if(i == x + 1){
                        test.append(a[n]);
                    }
                }
                if(isPal(test.toString())){
                    System.out.println(test.toString());
                    tru = true;
                    break;
                }
            }
            if(tru){
                break;
            }

        }
        if(!tru){
            System.out.println("NA");
        }

    }

    public static boolean isPal(String s) {

        for (int i = 0; i < s.length() / 2; i++) {
            if (s.charAt(i) != s.charAt(s.length() - 1 - i))
                return false;
        }
        return true;
    }
}

import java.util.*;
public class MrK {
    public static void main (String [] args){
        Scanner keyboard = new Scanner(System.in);
        String s = keyboard.next();
        String insert = "NA";
        int i = 0;
        while (insert.equals("NA") && i < s.length() ){
            insert = isPalindrome(s,i);
            i++;
        }
        System.out.println(insert);
    }
    public static String isPalindrome(String s , int position){
        char [] 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'};
        for(int i=0;i<alphabet.length;i++){
            String insert = "";
            if(position <=s.length()-1){
                insert = s.substring(0,position) + alphabet[i] + s.substring(position);
            }
            else insert = s + alphabet[i];
            System.out.println(insert);
            boolean pal = true;
            for (int j=0;j<insert.length()/2;j++){
                char a = insert.charAt(j);
                char b = insert.charAt(insert.length()-j-1);
                if(insert.charAt(j) != insert.charAt(insert.length()-j-1)) pal = false;
                System.out.println(a + " , " + b);
                System.out.println(pal);
            }
            if(pal)return insert;
        }
        return "NA";
    }

}

import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner (System.in);
		String s = input.nextLine();
		int low = 0 ;
		int afterlow =1;
		int high = s.length()-1;
		int beforehigh = s.length()-2;
		boolean bol = true ;int stage = -1;

		if (s.charAt(low) == s.charAt(high)){
			stage = 1;
			bol = ispalindrome(s);
		}
		else if(s.charAt(afterlow) == s.charAt(high)){
			stage =2;
			String m = s.substring(1, s.length());
			bol = ispalindrome(m);
		}
		else if(s.charAt(low) == s.charAt(beforehigh)){
			stage = 3;
			String m = s.substring(0, s.length()-1);
			bol = ispalindrome(m);
		}
		else{
			bol=false;
		}

		if( bol == true && stage == 1){
			String s1=s.substring(0, s.length()/2);
			String s2 =s.substring(s.length()/2, s.length());
			System.out.println(s1+s.charAt(s.length()/2)+s2);
		}
		else if(bol == true && stage==2){
			System.out.println(s+s.charAt(0));
		}
		else if(bol==true&&stage==3){
			System.out.println(s.charAt(s.length()-1)+s);
		}
		else if (bol == false){
			System.out.println("NA");
		}
	}
		public static boolean ispalindrome(String z){
			int min = 0 ;
			int highh = z.length()-1;
			boolean bo=true;
			while(min<highh){
				if (z.charAt(min) != z.charAt(highh)){
					bo = false;break;
				}
				min++;highh--;
			}
			if(z.length()>2){
				int mi = min+1;
				if(z.charAt(mi) == z.charAt(highh)){
					String l = z.substring(0, (highh+1));
					String o = z.substring((highh+1), (z.length()));
					char c = z.charAt(min);
					z=l+c+o;
					bo = true ;
					System.out.println(z);System.exit(0);
				}
				int h = highh-1;
				if(z.charAt(min) == z.charAt(h)){
					String l = z.substring(0, (min));
					String o = z.substring((min), (z.length()));
					char c = z.charAt(highh);
					z=l+c+o;
					bo = true ;
					System.out.println(z);System.exit(0);
				}
			}
			return bo ;
		}
}

import java.util.Scanner;

public class KitayutasGift {
    //505a

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String s2 = "";
        String s3 = "";

        boolean found = false;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            for (int j = 0; j < s.length(); j++){
                s2 = s.substring(0,j) + c + s.substring(j);
                s3 = new StringBuilder(s).reverse().toString();
                if (s2.equals(s3)){
                    found = true;
                    break;
                }
            }
            if (found)
                break;
        }

        if (found)
            System.out.print(s2);
        else
            System.out.print("NA");
    }

}

import java.util.Scanner;

/**
 * Created by kate on 18/01/15.
 */
public class Palindrom {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String res = null;
        int n = s.length();
        if (isPalindrom(s)) {
            res = s.substring(0, n/2) + s.charAt(n/2) + s.substring(n/2);
        } else {
            for (int i = 0; i < n / 2; i++) {
                if (s.charAt(i) == s.charAt(n - i - 1))
                    continue;
                if (s.charAt(i + 1) == s.charAt(n - i - 1)) {
                    res = s.substring(0, n - i) + s.charAt(i) + s.substring(n-i);

                } else if (s.charAt(i) == s.charAt(n-i-2)) {
                    res = s.substring(0,i) + s.charAt(n-i-1) + s.substring(i);
                } else {
                    break;
                }
                if(!isPalindrom(res))
                    res = null;
                break;
            }
        }
        if (res == null) {
            res = "N/A";
        }
        System.out.println(res);
    }

    public static boolean isPalindrom(String s) {
        int n = s.length();
        for (int i = 0; i < n/2; i++) {
            if(s.charAt(i) != s.charAt(n-i -1))
                return false;
        }
        return true;
    }
}

import java.io.IOException;

/**
 * Created by kaaveh on 1/22/15.
 */

/*                        _
* _._ _..._ .-',     _.._(`))
*'-. `     '  /-._.-'    ',/
*   )         \            '.
*  / _    _    |             \
* |  a    a    /              |
* \   .-.                     ;
*  '-('' ).-'       ,'       ;
*     '-;           |      .'
*        \           \    /
*        | 7  .__  _.-\   \
*        | |  |  ``/  /`  /
*       /,_|  |   /,_/   /
*          /,_/      '`-'
*/

public class _505A_ {
    public static void main(String[] args) {   //I hope enjoy! :)

        kaaveh in = new kaaveh();
        String data = in.kLine(10);

        int size = data.length() / 2;
        int lng= data.length();
        String res = "";
        boolean palin = true;

        for (int i=0; i<size; i++){
            if (data.charAt(i) != data.charAt(lng-1-i)){
                res += data.substring(0,lng-i);
                res += data.charAt(i);
                if (data.substring(lng-i, lng) != "") {
                    res += data.substring(lng - i, lng);
                    System.out.println("------------------------------------------");
                }

                System.out.println(data.substring(0,lng-i) + ";");
                System.out.println(data.charAt(i) + ";");
                System.out.println(data.substring(lng-i, lng) + ";");
                break;
            }
        }

        if (res.equals("")){
            if (lng % 2 == 0){
                System.out.println(data.substring(0, size) + "a" + data.substring(size, lng));
            }else {
                System.out.println(data.substring(0, size) + data.charAt(size) + data.substring(size, lng));
            }
            System.exit(0);
        }
        String ress = res;

        lng--;

        for (int i=0; i<=lng; i++) {
            System.out.print(ress.charAt(i));
            System.out.print('-');
        }
        System.out.println();

        for (int i=0; i<size; i++){
            System.out.print(ress.charAt(i));
            System.out.print('-');
            System.out.println(ress.charAt(lng-i));
            if (ress.charAt(i) != ress.charAt(lng-i)){
                palin = false;
            }
        }
        if (palin)
            System.out.println(ress);
        else
            System.out.println("NA");
    }
}

class kaaveh{
    static String kLine (int maxLg)
    {
        byte lin[] = new byte [maxLg];
        int lg = 0, car = -1;
        String line = "";

        try
        {
            while (lg < maxLg)
            {
                car = System.in.read();
                if ((car < 0) || (car == '\n')) break;
                lin [lg++] += car;
            }
        }
        catch (IOException e)
        {
            return (null);
        }

        if ((car < 0) && (lg == 0)) return (null);  // eof
        return (new String (lin, 0, lg));
    }

    static String knex (int maxLg)
    {
        byte lin[] = new byte [maxLg];
        int lg = 0, car = -1;
        String line = "";

        try
        {

            while ((car < 0) || (car == '\n') || (car == ' ') || (car == '\t') || (car == '\r'))
                car = System.in.read();

            while (lg < maxLg)
            {
                if ((car < 0) || (car == '\n') || (car == ' ') || (car == '\t') || (car == '\r')) break;
                lin [lg++] += car;
                car = System.in.read();
            }
        }
        catch (IOException e)
        {
            return (null);
        }

        if ((car < 0) && (lg == 0)) return (null);  // eof
        return (new String (lin, 0, lg));
    }

    static int kint()
    {
        return Integer.parseInt(knex(11));
    }

    static long kLong()
    {
        return Long.parseLong(knex(20));
    }

    static double kdouble()
    {
        return Double.parseDouble(knex(100));
    }
}

/**
 * Created by user on 12/15/2014.
 */
import java.util.
        *;
public class three
{
    public static int[] arr = new int[1000000];

    public static void main(String[] args)
    {
        Scanner input = new Scanner(System.in);
        String s = input.next();
       // System.out.println(checkPal(s));
        StringBuilder ret = new StringBuilder(s);
        if(checkPal(s))
        {
            ret.insert(s.length()/2,s.charAt(s.length()/2));
            System.out.println(ret);
        }
        else
        {
            ret.append(s.charAt(0));
            if(checkPal(ret.toString()))
                System.out.println(ret);
            else
                System.out.println("NA");
        }

    }
    public static boolean checkPal(String s)
    {
        int mask = 0;
        int[] arr = new int[s.length()];
        if(s.length() %2 == 0){
            for(int i = 0; i < s.length()/2; i++)
                if(s.charAt(i) == s.charAt(s.length() - i-1))
                {
                    arr[i] = 1;
                    arr[s.length() - i - 1] = 1;
                }
            for(int i = 0; i < arr.length; i++)
                if(arr[i] == 0)
                    return false;
            return true;
        }
        else
        {
            for(int i = 0; i <= s.length()/2; i++)
                if(s.charAt(i) == s.charAt(s.length() - i-1))
                {
                    arr[i] = 1;
                    arr[s.length() - i - 1] = 1;
                }
            for(int i = 0; i < arr.length; i++)
                if(arr[i] == 0)
                    return false;
            return true;
        }

    }
}

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.InputMismatchException;

public final class MrKitayutasGift
{
	private static InputReader reader;
	private static OutputWriter writer;

	public static void main(String[] args)
	{
		MrKitayutasGift gift = new MrKitayutasGift();

		reader = gift.new InputReader(System.in);
		writer = gift.new OutputWriter(System.out);

		getAttributes();

		writer.flush();

		reader.close();
		writer.close();
	}

	public static void getAttributes()
	{
		String s = reader.next();

		if (isPalindrome(s))
		{
			String answer = "";
			int length = s.length();

			for (int i = 0; i < length / 2; i++)
				answer += s.charAt(i);

			answer += s.charAt(length / 2);

			for (int i = length / 2; i < length; i++)
				answer += s.charAt(i);

			writer.println(answer);

			return;
		}

		String answer;
		int length, count, pos;
		boolean result;

		answer = "";
		length = s.length();
		count = 0;
		pos = 0;
		result = false;

		int i, j;

		i = 0;
		j = length - 1;

		while (s.charAt(i) == s.charAt(j) && i < length / 2)
		{
			// System.out.println("current i : " + i + ", j : " + j);

			i++;
			j--;
		}

		while (true && i < length / 2)
		{
			// System.out.println("current i : " + i + ", j : " + j + ", count : " + count);

			if (s.charAt(i) == s.charAt(j - 1))
			{
				// System.out.println("here");

				if (isPalindrome(s.substring(i, j)))
				{
					pos = i;

					// System.out.println("postiion is : " + pos);

					break;
				}
				else
				{
					writer.println("NA");

					return;
				}
			}
			else if (s.charAt(i + 1) == s.charAt(j))
			{
				// System.out.println("yo!!");

				if (isPalindrome(s.substring(i + 1, j + 1)))
				{
					pos = j;

					// System.out.println("position is : " + pos);

					break;
				}
				else
				{
					writer.println("NA");

					return;
				}
			}
			else if (s.charAt(i) != s.charAt(j))
				count++;
			else
			{
				writer.println("NA");

				return;
			}

			if (count > 1)
				break;

			// System.out.println("leaving i : " + i + ", j : " + j + ", count : " + count);

			i++;
			j--;
		}

		// System.out.println("count : " + count + ", pos : " + pos);

		if (count <= 1)
			result = true;

		if (result == false)
			writer.println("NA");
		else
		{
			if (length % 2 != 0)
			{
				if (pos > length / 2)
				{
					if (s.charAt(length / 2) != s.charAt(length / 2 + 1))
						result = false;
				}
				else if (s.charAt(length / 2) != s.charAt(length / 2 - 1))
					result = false;
			}

			if (!result)
			{
				writer.println("NA");

				return;
			}

			if (pos < length / 2)
			{
				for (int k = 0; k < pos; k++)
					answer += s.charAt(k);

				answer += s.charAt(length - 1 - pos);

				for (int k = pos; k < length; k++)
					answer += s.charAt(k);
			}
			else
			{
				for (int k = 0; k <= pos; k++)
					answer += s.charAt(k);

				answer += s.charAt(length - 1 - pos);

				for (int k = pos + 1; k < length; k++)
					answer += s.charAt(k);
			}

			writer.println(answer);
		}
	}

	public static boolean isPalindrome(String s)
	{
		int length = s.length();

		for (int i = 0; i < length / 2; i++)
			if (s.charAt(i) != s.charAt(length - 1 - i))
				return false;

		return true;
	}

	class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int read()
		{
			if (numChars == -1)
				throw new InputMismatchException();

			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}

			return buf[curChar++];
		}

		public int nextInt()
		{
			int c = read();

			while (isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-')
			{
				sgn = -1;
				c = read();
			}

			int res = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();

				res *= 10;
				res += c & 15;

				c = read();
			} while (!isSpaceChar(c));

			return res * sgn;
		}

		public long nextLong()
		{
			int c = read();

			while (isSpaceChar(c))
				c = read();

			int sign = 1;

			if (c == '-')
			{
				sign = -1;

				c = read();
			}

			long result = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();

				result *= 10;
				result += c & 15;

				c = read();
			} while (!isSpaceChar(c));

			return result * sign;
		}

		public float nextFloat() // problematic
		{
			float result, div;
			byte c;

			result = 0;
			div = 1;
			c = (byte) read();

			while (c <= ' ')
				c = (byte) read();

			boolean isNegative = (c == '-');

			if (isNegative)
				c = (byte) read();

			do
			{
				result = result * 10 + c - '0';
			} while ((c = (byte) read()) >= '0' && c <= '9');

			if (c == '.')
				while ((c = (byte) read()) >= '0' && c <= '9')
					result += (c - '0') / (div *= 10);

			if (isNegative)
				return -result;

			return result;
		}

		public double nextDouble() // not completely accurate
		{
			double ret = 0, div = 1;
			byte c = (byte) read();

			while (c <= ' ')
				c = (byte) read();

			boolean neg = (c == '-');

			if (neg)
				c = (byte) read();

			do
			{
				ret = ret * 10 + c - '0';
			} while ((c = (byte) read()) >= '0' && c <= '9');

			if (c == '.')
				while ((c = (byte) read()) >= '0' && c <= '9')
					ret += (c - '0') / (div *= 10);

			if (neg)
				return -ret;

			return ret;
		}

		public String next()
		{
			int c = read();

			while (isSpaceChar(c))
				c = read();

			StringBuilder res = new StringBuilder();

			do
			{
				res.appendCodePoint(c);

				c = read();
			} while (!isSpaceChar(c));

			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public void close()
		{
			try
			{
				stream.close();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}

	}

	class OutputWriter
	{
		private PrintWriter writer;

		public OutputWriter(OutputStream stream)
		{
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
					stream)));
		}

		public OutputWriter(Writer writer)
		{
			this.writer = new PrintWriter(writer);
		}

		public void println(int x)
		{
			writer.println(x);
		}

		public void print(int x)
		{
			writer.print(x);
		}

		public void println(int array[], int size)
		{
			for (int i = 0; i < size; i++)
				println(array[i]);
		}

		public void print(int array[], int size)
		{
			for (int i = 0; i < size; i++)
				print(array[i] + " ");
		}

		public void println(long x)
		{
			writer.println(x);
		}

		public void print(long x)
		{
			writer.print(x);
		}

		public void println(long array[], int size)
		{
			for (int i = 0; i < size; i++)
				println(array[i]);
		}

		public void print(long array[], int size)
		{
			for (int i = 0; i < size; i++)
				print(array[i]);
		}

		public void println(float num)
		{
			writer.println(num);
		}

		public void print(float num)
		{
			writer.print(num);
		}

		public void println(double num)
		{
			writer.println(num);
		}

		public void print(double num)
		{
			writer.print(num);
		}

		public void println(String s)
		{
			writer.println(s);
		}

		public void print(String s)
		{
			writer.print(s);
		}

		public void println()
		{
			writer.println();
		}

		public void printSpace()
		{
			writer.print(" ");
		}

		public void flush()
		{
			writer.flush();
		}

		public void close()
		{
			writer.close();
		}

	}

}

/*
 *
 * reviive reviave
 */

import java.io.*;
import java.util.*;

public class Main {
    static boolean isPalindorme(String s){
        int limit = s.length();
        if(limit%2 == 0) limit/=2;
        else limit = (s.length()-1) / 2;
        for(int i=0 ; i<limit ; i++){
            if(s.charAt(i)!=s.charAt(s.length()-i-1)) return false;
        }
        return true;
    }

    public static void main(String[] args) throws Exception{
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String s = bf.readLine();
        boolean ans = false;
        int limit = s.length();
        if(limit%2 == 0) limit/=2;
        else limit = (s.length()-1) / 2;
        ArrayList<Character> sd = new ArrayList<Character>();
        for(int i=0  ; i<s.length() ; i++){
            sd.add(s.charAt(i));
        }
        for(int i=0 ; i<limit ; i++){
            if(s.charAt(i)!=s.charAt(s.length()-i-1)){
                sd.add(s.length()-i,s.charAt(i));
                StringBuilder sv = new StringBuilder();
                for(Character c: sd) sv.append(c);
                s = sv.toString();
                ans = true;
                break;
            }
        }
        if(!ans){
            if(s.length()%2==1) {
                sd.add(limit,s.charAt(limit));
                StringBuilder sv = new StringBuilder();
                for(Character c: sd) sv.append(c);
                s = sv.toString();
            }
            else{
                sd.add(limit,'a');
                StringBuilder sv = new StringBuilder();
                for(Character c: sd) sv.append(c);
                s = sv.toString();
            }
        }
        if(isPalindorme(s)) System.out.println(s);
        else System.out.println("NA");

    }
}

import java.util.*;

/**
 *
 * @author Hartha
 */
public class MrKitayutaSGift {

    public static boolean pal(String word)
    {
        int length = word.length();
        for(int i = 0; i < length /2; i++)
            if(word.charAt(i) != word.charAt(length - 1 - i))
                return false;
        return true;
    }
    public static void main(String[] args) {
        Scanner sin = new Scanner(System.in);
        String word = sin.next();

        if(word.length() % 2 != 0 && pal(word))
        {
            System.out.println("NA");
            return;
        }

        for(int i = 0; i < word.length(); i++)
        {
            char ch = word.charAt(i);
            for(int j = 0; j < word.length(); j++)
                if(pal(word.substring(0, j) + ch + word.substring(j)))
                {
                    System.out.println(word.substring(0, j) + ch + word.substring(j));
                     return;
                }
            if(pal(word+ch))
            {
                System.out.println(word+ch);
                return;
            }

        }
        System.out.println("NA");
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class MakePalindrom {
    static String makeLetter(String s, int position) {
        String rs = "";
        List<Character> word = new ArrayList<Character>();
        for (char c : s.toCharArray())
            word.add(c);
        if (word.size() / 2 > position)
            word.add(word.size() - position, word.get(position));
        else
            word.add(word.size() - position - 1, word.get(position));
        for (Character c : word)
            rs += c;
        return rs;
    }

    static String deleteLetter(String s, int position) {
        String rs = "";
        List<Character> word = new ArrayList<Character>();
        for (char c : s.toCharArray())
            word.add(c);
        word.remove(position);
        for (Character c : word)
            rs += c;
        return rs;
    }

    static String putInMiddleLetter(String s) {
        String rs = "";
        List<Character> word = new ArrayList<Character>();
        for (char c : s.toCharArray())
            word.add(c);
        word.add(word.size() / 2, word.get(word.size() / 2));
        for (Character c : word)
            rs += c;
        return rs;
    }

    static boolean checkPalindrom(String s) {
        List<Character> word = new ArrayList<Character>();
        for (char c : s.toCharArray())
            word.add(c);
        int i = 0;
        int j = word.size() - 1;
        while (i < j) {
            if (word.get(i) != word.get(j))
                return false;
            i++;
            j--;
        }
        return true;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        String s = r.readLine();
        if (checkPalindrom(s))
            System.out.print(putInMiddleLetter(s));
        else {
            for (int i = 0; i < s.length(); ++i) {
                if (checkPalindrom(deleteLetter(s, i))) {
                    System.out.print(makeLetter(s, i));
                    return;

                }
            }
        }
    }

}

import java.io.IOException;

/**
 * Created by kaaveh on 1/22/15.
 */

/*                        _
* _._ _..._ .-',     _.._(`))
*'-. `     '  /-._.-'    ',/
*   )         \            '.
*  / _    _    |             \
* |  a    a    /              |
* \   .-.                     ;
*  '-('' ).-'       ,'       ;
*     '-;           |      .'
*        \           \    /
*        | 7  .__  _.-\   \
*        | |  |  ``/  /`  /
*       /,_|  |   /,_/   /
*          /,_/      '`-'
*/

public class _505A_ {
    public static void main(String[] args) {   //I hope enjoy! :)

        kaaveh in = new kaaveh();
        String data = in.kLine(10);

        int size = data.length() / 2;
        int lng= data.length();
        String res = "";
        boolean palin = true;

        for (int i=0; i<size; i++){
            if (data.charAt(i) != data.charAt(lng-1-i)){
                res += data.substring(0,lng-i) + data.charAt(i) + data.substring(lng-i, lng);
                break;
            }
        }

        if (res.equals("")){
            if (lng % 2 == 0){
                System.out.println(data.substring(0, size) + "a" + data.substring(size, lng));
            }else {
                System.out.println(data.substring(0, size) + data.charAt(size) + data.substring(size, lng));
            }
            System.exit(0);
        }

        for (int i=0; i<size; i++){
            System.out.print(res.charAt(i));
            System.out.println(res.charAt(lng-i));
            if (res.charAt(i) != res.charAt(lng-i)){
                palin = false;
            }
        }
        if (palin)
            System.out.println(res);
        else
            System.out.println("NA");
    }
}

class kaaveh{
    static String kLine (int maxLg)
    {
        byte lin[] = new byte [maxLg];
        int lg = 0, car = -1;
        String line = "";

        try
        {
            while (lg < maxLg)
            {
                car = System.in.read();
                if ((car < 0) || (car == '\n')) break;
                lin [lg++] += car;
            }
        }
        catch (IOException e)
        {
            return (null);
        }

        if ((car < 0) && (lg == 0)) return (null);  // eof
        return (new String (lin, 0, lg));
    }

    static String knex (int maxLg)
    {
        byte lin[] = new byte [maxLg];
        int lg = 0, car = -1;
        String line = "";

        try
        {

            while ((car < 0) || (car == '\n') || (car == ' ') || (car == '\t') || (car == '\r'))
                car = System.in.read();

            while (lg < maxLg)
            {
                if ((car < 0) || (car == '\n') || (car == ' ') || (car == '\t') || (car == '\r')) break;
                lin [lg++] += car;
                car = System.in.read();
            }
        }
        catch (IOException e)
        {
            return (null);
        }

        if ((car < 0) && (lg == 0)) return (null);  // eof
        return (new String (lin, 0, lg));
    }

    static int kint()
    {
        return Integer.parseInt(knex(11));
    }

    static long kLong()
    {
        return Long.parseLong(knex(20));
    }

    static double kdouble()
    {
        return Double.parseDouble(knex(100));
    }
}

import java.io.*;
import java.util.*;

public class Task {

	public static void main(String[] args) throws IOException {
		new Task().solve();
	}

	PrintWriter out;
	int mul = 26+26+10;
	int nv = 4000;
	int[][] g;
	int[] pos;
	int cnt = 0;
	void solve() throws IOException{
		Reader in = new Reader("input.txt");
		out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );
		//out = new PrintWriter(new FileWriter(new File("output.txt")));

		String s = in.nextString();

		int l = 0;
		int r = s.length()-1;
		int pos = -2;
		int sym = -1;
		boolean insert = false;

		while (r - l > 0) {
			if (s.charAt(l) == s.charAt(r)) {
				l++;
				r--;
			}
			else
			if (pos == -2 && s.charAt(l+1) == s.charAt(r))
			{
				pos = r;
				sym = l;
				l++;
				insert = true;
			}
			else
			if (pos == -2 && s.charAt(l) == s.charAt(r-1)) {
				pos = l-1;
				sym = r;
				r--;
				insert = true;
			}
			else {
				System.out.print("NA");
				return;
			}
		}
		for (int i = 0; i < s.length(); i++) {
			if (pos == i-1) out.print(s.charAt(sym));
			if (pos == -2 && i == s.length()/2) out.print(s.charAt(i));
			out.print(s.charAt(i));
		}
		if (pos == s.length()-1)
			out.print(s.charAt(sym));

		out.flush();
		out.close();
	}

	long pow(int x, int m) {
		if (m == 0)
			return 1;
		return x*pow(x, m-1);
	}

}

	class Pair {

		int v;
		int z;

		Pair (int v, int z) {
			this.v = v;
			this.z = z;
		}

	}

	class Item implements Comparable<Item> {

		int v;
		int l;
		int z;

		Item(int v, int l, int z) {
			this.v = v;
			this.l = l;
			this.z = z;
		}

		@Override
		public int compareTo(Item item) {

			if (l > item.l)
				return 1;
			else
			if (l < item.l)
				return -1;
			else {
				if (z > item.z)
					return 1;
				else
				if (z < item.z)
					return -1;
				return 0;
			}

		}

	}

	class Reader {

	    StringTokenizer token;
	    BufferedReader in;

	    public Reader(String file) throws IOException {
	        //in = new BufferedReader( new FileReader( file ) );
	        in = new BufferedReader( new InputStreamReader( System.in ) );
	    }

	    public byte nextByte() throws IOException {
	        return Byte.parseByte(Next());
	    }

	    public int nextInt() throws IOException {
	        return Integer.parseInt(Next());
	    }

	    public long nextLong() throws IOException {
	        return Long.parseLong(Next());
	    }

	    public String nextString() throws IOException {
	        return in.readLine();
	    }

	    private String Next() throws IOException {
	        while (token == null || !token.hasMoreTokens()) {
	            token = new StringTokenizer(in.readLine());
	        }
	        return token.nextToken();
	    }

	}

import java.util.*;
public class Mod4 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		String pattern = sc.nextLine();
		sb.append(pattern);
		int i=0,j=pattern.length()-1;
		int unMatchPoint=0;
		char notMatch = '1';
		int misCounter = 0;
		while(i<=j){
			//reverse matching
			if(pattern.charAt(i)== pattern.charAt(j)){
				i++; j--;
				continue;
			}

			else if(pattern.charAt(i)!= pattern.charAt(j)){
				unMatchPoint = i;
				notMatch = pattern.charAt(i);
				i++;
				misCounter++;
			}
		}

		if(misCounter>=2){
			System.out.println("NA");
		} else{
			if(misCounter==0){
				int temp = pattern.length()/2;
				sb.insert(temp , pattern.charAt(temp));
				System.out.println(sb.toString());
			}
			if(misCounter == 1){
				sb.insert(pattern.length()-unMatchPoint, notMatch);
				System.out.println(sb.toString());
			}
		}
		sc.close();
	}
}

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.InputMismatchException;

public final class MrKitayutasGift
{
	private static InputReader reader;
	private static OutputWriter writer;

	public static void main(String[] args)
	{
		MrKitayutasGift gift = new MrKitayutasGift();

		reader = gift.new InputReader(System.in);
		writer = gift.new OutputWriter(System.out);

		getAttributes();

		writer.flush();

		reader.close();
		writer.close();
	}

	public static void getAttributes()
	{
		String s = reader.next();

		if (isPalindrome(s))
		{
			String answer = "";
			int length = s.length();

			for (int i = 0; i < length / 2; i++)
				answer += s.charAt(i);

			answer += s.charAt(length / 2);

			for (int i = length / 2; i < length; i++)
				answer += s.charAt(i);

			writer.println(answer);

			return;
		}

		String answer;
		int length, count, pos;
		boolean result;

		answer = "";
		length = s.length();
		count = 0;
		pos = 0;
		result = false;

		int i, j;

		i = 0;
		j = length - 1;

		while (s.charAt(i) == s.charAt(j) && i < length / 2)
		{
			// System.out.println("current i : " + i + ", j : " + j);

			i++;
			j--;
		}

		while (true && i < length / 2)
		{
			// System.out.println("current i : " + i + ", j : " + j + ", count : " + count);

			if (s.charAt(i) == s.charAt(j - 1))
			{
				// System.out.println("here");

				j--;
				pos = i;
				count++;
			}
			else if (s.charAt(i + 1) == s.charAt(j))
			{
				// System.out.println("yo!!");

				i++;
				pos = j;
				count++;
			}
			else if (s.charAt(i) != s.charAt(j))
				count++;

			if (count > 1)
				break;

			// System.out.println("leaving i : " + i + ", j : " + j + ", count : " + count);

			i++;
			j--;
		}

		// System.out.println("count : " + count + ", pos : " + pos);

		if (count == 1)
			result = true;

		if (result == false)
			writer.println("NA");
		else
		{
			if (length % 2 != 0)
			{
				if (pos > length / 2)
				{
					if (s.charAt(length / 2) != s.charAt(length / 2 + 1))
						result = false;
				}
				else if (s.charAt(length / 2) != s.charAt(length / 2 - 1))
					result = false;
			}

			if (!result)
			{
				writer.println("NA");

				return;
			}

			if (pos < length / 2)
			{
				for (int k = 0; k < pos; k++)
					answer += s.charAt(k);

				answer += s.charAt(length - 1 - pos);

				for (int k = pos; k < length; k++)
					answer += s.charAt(k);
			}
			else
			{
				for (int k = 0; k <= pos; k++)
					answer += s.charAt(k);

				answer += s.charAt(length - 1 - pos);

				for (int k = pos + 1; k < length; k++)
					answer += s.charAt(k);
			}

			writer.println(answer);
		}
	}

	public static boolean isPalindrome(String s)
	{
		int length = s.length();

		for (int i = 0; i < length / 2; i++)
			if (s.charAt(i) != s.charAt(length - 1 - i))
				return false;

		return true;
	}

	class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int read()
		{
			if (numChars == -1)
				throw new InputMismatchException();

			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}

			return buf[curChar++];
		}

		public int nextInt()
		{
			int c = read();

			while (isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-')
			{
				sgn = -1;
				c = read();
			}

			int res = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();

				res *= 10;
				res += c & 15;

				c = read();
			} while (!isSpaceChar(c));

			return res * sgn;
		}

		public long nextLong()
		{
			int c = read();

			while (isSpaceChar(c))
				c = read();

			int sign = 1;

			if (c == '-')
			{
				sign = -1;

				c = read();
			}

			long result = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();

				result *= 10;
				result += c & 15;

				c = read();
			} while (!isSpaceChar(c));

			return result * sign;
		}

		public float nextFloat() // problematic
		{
			float result, div;
			byte c;

			result = 0;
			div = 1;
			c = (byte) read();

			while (c <= ' ')
				c = (byte) read();

			boolean isNegative = (c == '-');

			if (isNegative)
				c = (byte) read();

			do
			{
				result = result * 10 + c - '0';
			} while ((c = (byte) read()) >= '0' && c <= '9');

			if (c == '.')
				while ((c = (byte) read()) >= '0' && c <= '9')
					result += (c - '0') / (div *= 10);

			if (isNegative)
				return -result;

			return result;
		}

		public double nextDouble() // not completely accurate
		{
			double ret = 0, div = 1;
			byte c = (byte) read();

			while (c <= ' ')
				c = (byte) read();

			boolean neg = (c == '-');

			if (neg)
				c = (byte) read();

			do
			{
				ret = ret * 10 + c - '0';
			} while ((c = (byte) read()) >= '0' && c <= '9');

			if (c == '.')
				while ((c = (byte) read()) >= '0' && c <= '9')
					ret += (c - '0') / (div *= 10);

			if (neg)
				return -ret;

			return ret;
		}

		public String next()
		{
			int c = read();

			while (isSpaceChar(c))
				c = read();

			StringBuilder res = new StringBuilder();

			do
			{
				res.appendCodePoint(c);

				c = read();
			} while (!isSpaceChar(c));

			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public void close()
		{
			try
			{
				stream.close();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}

	}

	class OutputWriter
	{
		private PrintWriter writer;

		public OutputWriter(OutputStream stream)
		{
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
					stream)));
		}

		public OutputWriter(Writer writer)
		{
			this.writer = new PrintWriter(writer);
		}

		public void println(int x)
		{
			writer.println(x);
		}

		public void print(int x)
		{
			writer.print(x);
		}

		public void println(int array[], int size)
		{
			for (int i = 0; i < size; i++)
				println(array[i]);
		}

		public void print(int array[], int size)
		{
			for (int i = 0; i < size; i++)
				print(array[i] + " ");
		}

		public void println(long x)
		{
			writer.println(x);
		}

		public void print(long x)
		{
			writer.print(x);
		}

		public void println(long array[], int size)
		{
			for (int i = 0; i < size; i++)
				println(array[i]);
		}

		public void print(long array[], int size)
		{
			for (int i = 0; i < size; i++)
				print(array[i]);
		}

		public void println(float num)
		{
			writer.println(num);
		}

		public void print(float num)
		{
			writer.print(num);
		}

		public void println(double num)
		{
			writer.println(num);
		}

		public void print(double num)
		{
			writer.print(num);
		}

		public void println(String s)
		{
			writer.println(s);
		}

		public void print(String s)
		{
			writer.print(s);
		}

		public void println()
		{
			writer.println();
		}

		public void printSpace()
		{
			writer.print(" ");
		}

		public void flush()
		{
			writer.flush();
		}

		public void close()
		{
			writer.close();
		}

	}

}

/*
 *
 * reviive reviave
 */

import java.util.Scanner;

/**
 *
 * @author mav3n
 */
public class A286 {

    public static boolean isPalindrome(String s){
        boolean rs = true;
        int l = s.length();
        for(int i=0;i<l/2;i++){
            if(s.charAt(i)==s.charAt(l-i-1)){
               continue;
            }
            rs=false;break;
        }
        return rs;
    }

    public static void main(String... arg){
                Scanner sc = new Scanner(System.in);
                String s = sc.nextLine();

                int l = s.length();

                boolean pl = isPalindrome(s);

                String result="";
                if(pl){
                    if(l%2==0){
                        result = s.substring(0, l/2)+"a"+s.substring(l/2, l);
                    }
                    else{
                        result = s.substring(0, l/2)+s.charAt(l/2)+s.substring(l/2, l);
                    }
                }else{
                 for(int i=0;i<l/2;i++){
                    if(s.charAt(i)==s.charAt(l-i-1)){
                        continue;
                    }
                    else{
                        boolean flag=true;
                        if(s.charAt(i)==s.charAt(l-i-2)){
                            result=s.substring(0, i)+s.charAt(l-i-1)+s.substring(i, l);
                            if(!isPalindrome(result)){
                                result="NA";
                            }
                            flag=false;
                        }
                        if(result=="NA" || s.charAt(i+1)==s.charAt(l-i-1)){
                            result=s.substring(0, l-i)+s.charAt(i)+s.substring(l-i, l);

                            if(!isPalindrome(result)){
                                result="NA";
                            }
                            flag=false;
                        }
                        if(flag){
                            result="NA";
                        }
                        break;
                    }
                }

                }
                System.out.println(result);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        BufferedReader bufferedReader = new BufferedReader(
                new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();
        String s = bufferedReader.readLine();
        builder.append(s);
        boolean char_inserted = false;
        // boolean char_inserted = false;
        int len = s.length();
        char tmp = 0;
        String result = "";
        for (int i = 0; i < len / 2; i++) {
            if ((tmp = builder.charAt(i)) == builder.charAt(len - i - 1)) {
                continue;
            } else {
                if ((tmp = builder.charAt(i)) != builder.charAt(len - i - 1)
                        && !char_inserted) {
                    builder.insert(len - i , tmp);
                    len+=1;
                    char_inserted = true;
                } else {
                    result = "NA";
                    break;
                }
            }
        }
        if (result.equals("NA")) {
            System.out.println(result);
        } else {
            if (s.length() < builder.length()) {
                System.out.println(builder.toString());
            }else{
                builder.insert(len / 2, tmp);
                System.out.println(builder.toString());
            }
        }

    }

}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package Codeforces;

/**
 *
 * @author Administrator
 */
import java.lang.String;
import java.util.Scanner;
import java.lang.StringBuffer;
public class c505A {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int m = s.length();
        if (m % 2 == 1) m++;
        if(s.length() % 2 == 0 && kt(s))
        {
            for (int i=0;i<=m/2-1;i++) System.out.print(s.charAt(i));
            System.out.print("a");
            for (int i=m/2;i<=m-1;i++) System.out.print(s.charAt(i));
        }else
        {
            int k=0;
            for (int i=0;i <= m/2;i++)
            {
                StringBuffer s0 = new StringBuffer();
                s0.insert(0, s);
                s0.insert(s.length()-i, s.charAt(i));
                String s3 = new String(s0);
                if (kt(s3))
                {
                    k = 1;
                    System.out.println(s0);
                    break;
                }
            }
            if (k == 0) System.out.println("NA");
        }
    }

    public static boolean kt(String s1) {
        String s2 = "";
        for (int i1 = s1.length() - 1; i1 >= 0; i1--) {
            s2 += s1.charAt(i1);
        }
        if (s1.equals(s2)) return true;
        else return false;
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ma {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String in = br.readLine();
        String out1="";
        String out2="";
        String out3="";

            out1 = in.substring(0, in.length() / 2)+"i"+in.substring((in.length() / 2));
            out2 = in+in.charAt(0);
            out3 = in.charAt(in.length()-1)+in;

            if(pal(out1)){
                System.out.println(out1);
            }
            else if(pal(out2)){
                System.out.println(out2);
            }
            else if(pal(out3)){
                System.out.println(out3);
            }
            else
                System.out.println("NA");

    }

    private static boolean pal(String out) {
        for(int i=0;i<out.length()/2;i++){
            if(out.charAt(i) != out.charAt(out.length()-i-1)){
                return false;
            }
        }
        return true;
    }

}

/*
 * PDPM IIITDM Jabalpur
 * Asutosh Rana
 */
import java.util.*;
import java.io.*;
import java.math.*;

public class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        InputReader in=new InputReader(System.in);
        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out=new PrintWriter(System.out);

        int t = 1;//in.readInt();

        while(t-->0){
            char[] S = in.readCharA();
            char[] A = new char[S.length+1];
            int flag=0;
            for(int i=0;i<S.length+1 && flag==0;i++){
            	for(int j=0;j<25 && flag==0;j++){
            		A[i] = (char)(j+'a');
            		for(int k=0,l=0;k<A.length;k++){
            			if(k!=i){
            				A[k]=S[l];
            				l++;
            			}
            		}
            		//out.println(A);
            		if(palin(A)){
            			out.println(A);
            			flag=1;break;
            		}
            	}

            }
            if(flag==0)
            	out.println("NA");
        }
        out.flush();
        out.close();
    }

    static boolean palin(char[] A){
    	for(int i=0;i<A.length/2;i++){
    		if(A[i]!=A[A.length-i-1])
    			return false;
    	}
    	return true;
    }
}

class InputReader{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream){this.stream = stream;}
    public int read(){
        if (numChars==-1) throw new InputMismatchException();
        if (curChar >= numChars){
            curChar = 0;
            try {numChars = stream.read(buf);}
            catch (IOException e){throw new InputMismatchException();}
            if(numChars <= 0) return -1;
        }
        return buf[curChar++];
    }

    public int readInt(){
        int c = read();
        while(isSpaceChar(c)) c = read();
        int sgn = 1;
        if (c == '-') {sgn = -1;c = read();}
        int res = 0;
        do {
            if(c<'0'||c>'9') throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        while (!isSpaceChar(c)); return res * sgn;
    }

    public void readInt(int[] A){
        for(int i=0;i<A.length;i++)
            A[i] = readInt();
    }

    public long readLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        while (!isSpaceChar(c));
        return res * sgn;
    }

    public void readLong(long[] A){
        for(int i=0;i<A.length;i++)
            A[i] = readLong();
    }

    public double readDouble() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E')
                return res * Math.pow(10, readInt());
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, readInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        return res * sgn;
    }

    public char[] readCharA(){
        return readString().toCharArray();
    }

    public String readString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public String next() {
        return readString();
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }

}

/**
 * Created by Cole on 9/4/15.
 */

import java.util.Scanner;
import java.lang.StringBuilder;

public class mrKitayutasGift {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String currentWord = sc.next();
        createPalindrome(currentWord);

    }

    public static void createPalindrome(String originalString) {
        int length = originalString.length();
        StringBuilder word = new StringBuilder(originalString);
        StringBuilder newPalindrome = new StringBuilder(word.insert(length/2, word.charAt(0)).toString());
        if (isPalindrome(newPalindrome)) {
            System.out.println(newPalindrome);
            return;
        }
        word = new StringBuilder(originalString);
        for (int i = 0; i < length / 2; i++) {
            word = new StringBuilder(originalString);
            if (word.charAt(i) != word.charAt(length - i - 1)) {
                //System.out.println("charAt " + i + ": " + word.charAt(i) + " charAt " + (length - i - 1) + ": " + word.charAt(length - i - 1));
                newPalindrome = new StringBuilder(word.insert(i, word.charAt(length - i - 1)).toString());
                if (isPalindrome(newPalindrome)) {
                    System.out.println(newPalindrome);
                    return;
                }
                word = new StringBuilder(originalString);
                newPalindrome = new StringBuilder(word.insert(length - i, word.charAt(i)).toString());
                if (isPalindrome(newPalindrome)) {
                    System.out.println(newPalindrome);
                    return;
                }
            }
        }
        System.out.println("NA");
    }

    public static boolean isPalindrome (StringBuilder word) {
        int length = word.length();
        for (int i = 0; i < length / 2; i++) {
            if (word.charAt(i) != word.charAt(length - i - 1)) {
                return false;
            }
        }
        return true;
    }

}

import java.util.Scanner;
public class Kitayuta_gift {
    public static void main(String args[])
    {
        Scanner input=new Scanner(System.in);
        String name=input.nextLine();
        int n=name.length();
        if(is_palindrome(name))
        {
            if(n%2==1)
                System.out.println(name.substring(0,(n/2)+1)+name.charAt(n/2)+name.substring((n/2)+1));
                else
                    System.out.println(name.substring(0,(n/2))+"c"+name.substring((n/2)));
        }
        else
        {
            System.out.println(add(name));
        }

    }
    public static boolean is_palindrome(String s)
    {
        for(int i=0;i<s.length()/2;i++)
        {
            if(s.charAt(i)!=s.charAt(s.length()-i-1))
                return false;
        }
        return true;
    }
    public static String add(String str)
    {
        String temp;
        for(int i=0;i<str.length()/2;i++)
        {
            if(str.charAt(i)!=str.charAt(str.length()-i-1))
            {
                str=str.substring(0,str.length()-i)+str.charAt(i)+str.substring(str.length()-i);
                if(is_palindrome(str))
                return str;
                else
                {
                    temp=str.substring(0,i)+str.charAt(str.length()-i-1)+str.substring(i);
                    if(is_palindrome(temp))
                        return temp;
                    else
                        return "NA";

                }
            }
        }
        return null;
    }

}

import java.util.*;
import java.io.*;
public class Kitayuta {
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		String word=sc.next();
		int insert=0;

		int num=0;
		int front=0;
		int back=word.length()-1;
		if(word.length()==1)
		{
			System.out.println(word+word);
			System.exit(0);
		}
		char f=word.charAt(0);
		char e=word.charAt(word.length()-1);
		if(word.length()>2&&isPalli(word+f))
		{
			System.out.println(word+f);
			System.exit(0);

		}
		else if(word.length()>2&&isPalli(e+word))
		{
			System.out.println(e+word);
			System.exit(0);

		}
		char temp='z';

		while(front<word.length()/2)
		{
			if(word.charAt(front)==word.charAt(back))
			{
				front++;
				back--;
			}
			else if((word.charAt(front+1)==word.charAt(back)))
			{
				temp=(word.charAt(front));
				//arr.put(insert++,String.valueOf(word.charAt(front)));
				insert=back+1;
				num++;
				front++;
			}
			else if ((word.charAt(front)==word.charAt(back-1)))
			{
				temp=(word.charAt(back));
				num++;
				insert=front;
				back--;

			}
			else
			{

				System.out.println("NA");
				System.exit(0);
			}

		}

		if(num==0)
		{
			if(word.length()%2==0)
			{
			String ans=word.substring(0,word.length()/2)+"y"+word.substring(word.length()/2);
			System.out.println(ans);
			}
			else
			{
				System.out.println(word.substring(0,word.length()/2)+word.charAt(word.length()/2)+word.substring(word.length()/2));
			}
			}
		else if(num>1)
		{
			System.out.println("NA");
		}
		else
		{
			String ans="";
			if(insert<0)
			{
				ans=temp+word;
			}
			else
			{
			ans=word.substring(0,insert)+temp+word.substring(insert);
			}

			System.out.println(ans);
			}

	}
	public static boolean isPalli(String word)
	{
		//System.out.println(word);
		Stack st= new Stack();
		for(int i=0;i<word.length()/2;i++)
		{
			st.push(word.charAt(i));
		}
		//System.out.println(st.isEmpty());
		for(int k=word.length()/2;k<word.length();k++)
		{
			//System.out.println(st.peek());
			if (!st.isEmpty()||(char)st.pop()!=word.charAt(k))
			{
				return false;
			}
		}

		return true;

	}
}

import java.util.Scanner;
public class KitayutaSGift {
public static void main(String[] args) {
     Scanner input=new Scanner(System.in);
     String s=input.next();
     String x="";
     for(int i=s.length()-1;i>=0;i--)
         x+=s.charAt(i);

     if(s.equals(x)){
         if(s.length()%2==0){
          StringBuilder z=new  StringBuilder(x);
          x=""+z.insert(s.length()/2,'y');
          }
         System.out.println(x);
      }
    else{
      int n=0;
      for(int i=0;i<s.length();i++)
       if(s.charAt(i)!=x.charAt(i)){
         StringBuilder z=new  StringBuilder(x);
         x=""+z.insert(i,s.charAt(i));
         n++;
           }
       if(n!=1)
         System.out.println("NA");
       else
         System.out.println(x);
       }
    }
}

import java.util.Scanner;

/**
 *
 * @author Tarango
 */
public class CF286 {
    public static void main(String[] args) {
        Scanner kb = new Scanner(System.in);
        String s;
        s = kb.nextLine();
        char box[] = {'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'};
        String ans = "",N,p1,p2;
        int flag = 0;
        for(int i = 0;i<26;i++){
            for(int c = 0;c<s.length();c++){
                if(c == 0){
                    N = "";
                    N = N + box[i] + s;
                    if(isPalin(N) == 1){
                        flag = 1;
                        ans = N;
                        break;
                    }
                }else if(c == 1){
                    N = ""+s.charAt(0);
                    N = N + box[i] + s.substring(1,s.length());
                    if(isPalin(N) == 1){
                        flag = 1;
                        ans = N;
                        break;
                    }
                }else if(c == s.length()-2){
                    N = "";
                    N = N + s.substring(0, s.length()-1) + box[i] + +s.charAt(s.length()-1);
                    if(isPalin(N) == 1){
                        flag = 1;
                        ans = N;
                        break;
                    }
                }
                else if(c == s.length()-1){
                    N = "";
                    N = N + s + box[i];
                    if(isPalin(N) == 1){
                        flag = 1;
                        ans = N;
                        break;
                    }
                }else{
                    p1 = s.substring(0, c);
                    p2 = s.substring(c, s.length());
                    N = p1;
                    N = N+ box[i] + p2;
                    if(isPalin(N) == 1){
                        flag = 1;
                        ans = N;
                        break;
                    }
                }
            }
            if(flag == 1) break;
        }
        if(flag == 1) System.out.println(ans);
        else System.out.println("NA");
    }

    public static int isPalin(String s){
        int i = 0,j = s.length()-1;
        while(i<j){
            if(s.charAt(i)!=s.charAt(j)) return 0;
            i++;j--;
        }
        return 1;
    }
}

import java.io.*;
import java.util.*;

public class Cf505A {

    public static void main(String args[]) throws IOException
    {
        InputReader in = new InputReader(System.in);
	PrintWriter w = new PrintWriter(System.out);
        StringBuilder s = new StringBuilder(in.readString());

        if(s.length()%2 != 0){
            s.append(s.charAt(0));
            if(isPalindrome(s)){
                System.out.println(s);
                return;
            } else{
                s.deleteCharAt(s.length()-1);
                s.reverse();
                s.append(s.charAt(0));
                if(isPalindrome(s)){
                System.out.println(s);
                return;
            }
            }
        } else{
            s.append(s.charAt(0));
            if(isPalindrome(s)){
                System.out.println(s);
                return;
            } else{
                s.deleteCharAt(s.length()-1);
                s.reverse();
                s.append(s.charAt(0));
                if(isPalindrome(s)){
                System.out.println(s);
                return;
            }
            }

        }

        System.out.println("NA");
        w.close();
    }
    static boolean isPalindrome(StringBuilder s){
        for(int i = 0; i < s.length()/2; i++){
            if(s.charAt(i) != s.charAt(s.length()- i- 1)) return false;
        }
        return true;
    }
      static class InputReader {

		private InputStream stream;
		private byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public String readString() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ProbA {
    public static void main(String[] args) throws IOException {
        String inputStr = "";
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        inputStr = br.readLine();

        //insert any char in middle --> thats's is!
        if (isPalindrom(inputStr) && inputStr.length() % 2 == 0) {
            System.out.println(inputStr.substring(0, inputStr.length() / 2)
                    + "a" + inputStr.substring(inputStr.length() / 2, inputStr.length()));

        //palindrom, but we can't insert only one letter
        } else if (isPalindrom(inputStr) && inputStr.length() % 2 == 1) {
            System.out.println("NA");

        } else if (isPalindrom(inputStr + inputStr.charAt(0))) {
            System.out.println(inputStr + inputStr.charAt(0));

        } else if (isPalindrom(inputStr.charAt(inputStr.length() - 1) + inputStr)) {
            System.out.println(inputStr.charAt(inputStr.length() - 1) + inputStr);

        } else {
            createPalindrom(inputStr);
        }
    }

    private static void createPalindrom(String s) {
        int len = s.length();
        String resultString = "";

        for (int i = 0, j = len - 1; i <= j; ) {
            if (s.charAt(i) == s.charAt(j)) {
                i++;
                j--;
            } else {
                    if (i - 1 >= 0) {
                        String res = putCharAtPos(s, s.charAt(j), i - 1);
                        if (isPalindrom(res)) {
                            System.out.println(res);
                            return;
                        }
                    }

                    if (j + 1 < len) {
                        String res = putCharAtPos(s, s.charAt(i), j + 1);
                        if (isPalindrom(res)) {
                            System.out.println(res);
                            return;
                        }
                    }

                    System.out.println("NA");
                    return;
            }
        }

        if (!resultString.isEmpty()) {
            System.out.println(resultString);
            return;
        }
    }

    private static boolean isPalindrom(String s) {
        char[] masString = s.toCharArray();
        boolean isPalindr = true;

        for (int i = 0, j = s.length() - 1; i <= j; i++, j--) {
            if (masString[i] != masString[j]) {
                isPalindr = false;
                break;
            }
        }

        return isPalindr;
    }

    private static String putCharAtPos(String s, char c, int pos) {
        char[] res = new char[s.length() + 1];

        if (pos == 0) {
            res[0] = s.charAt(0);
            res[1] = c;
            for (int i = 2; i <= s.length(); i++) {
                res[i] = s.charAt(i - 1);
            }
            return String.valueOf(res);
        }

        for (int i = 0; i < pos; i++) {
            res[i] = s.charAt(i);
        }

        res[pos] = c;

        for (int i = pos + 1; i <= s.length(); i++) {
            res[i] = s.charAt(i - 1);
        }

        return String.valueOf(res);
    }
}

import java.util.Scanner;
public class tst{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        String s=sc.next(),temp="";
        int i=0,n=s.length();
        for(i=0;i<n;i++){
            for(char ch='a';ch<='z';ch++){
                temp=s.substring(0,i)+ch+s.substring(i);
                if(isPalin(temp)){
                    System.out.println(temp);
                    break;
                }
            }
        }
        if(i==n)System.out.println("-1");
    }
    private static boolean isPalin(String s){
        int i=0,j=s.length()-1;
        while(i<j){
            if(s.charAt(i)!=s.charAt(j))return false;
            i++;
            j--;
        }
        return true;
    }
}

import java.util.*;

public class Main {
    public static void main (String args[]) {
        Scanner sc = new Scanner(System.in);
        System.out.print(kitayuta(sc.nextLine())); }

    public static boolean ispalindrome(String s) {
        for (int i = 0; i < s.length()/2; i++) {
            if (s.charAt(i) != s.charAt(s.length()-1-i))
                return false; }
        return true; }

    public static String kitayuta(String s) {
        if(ispalindrome(s)) {
            if (s.length() % 2 == 0)
              return new StringBuilder(s).insert(s.length()/2, "y").toString();
            else
              return new StringBuilder(s).insert(s.length()/2, s.charAt(s.length()/2)).toString();
        }
        for (int i = 0; i < s.length()/2; i++) {
            if (s.charAt(i) != s.charAt(s.length()-1-i)) {
               String insert = new StringBuilder(s).insert(s.length()-i, s.charAt(i)).toString();
               if (ispalindrome(insert))
                    return insert;
            }
        }
        return s;
    }
}

import java.util.Scanner;

/**
 * Created by markdaniel on 1/29/16.
 */
public class Exercise2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        if (scanner.hasNextLine()) {
            System.out.println(doKitayuta(scanner.nextLine()));
        }
    }

    public static String doKitayuta(String word) {
        int wordLen = word.length();
        StringBuilder sb = new StringBuilder();
        if (wordLen == 1) {
            return sb.append(word + word).toString();
        }
        if (wordLen == 2) {
            if (word.charAt(0) == word.charAt(1)) {
                return sb.append("" + word.charAt(0) + 'x' + word.charAt(1)).toString();
            } else {
                return sb.append(word.charAt(1) + word).toString();
            }
        }

        int start = 0;
        int end = wordLen - 1;

        word = recurse(word, start, end, false);

        return word;
    }

    public static String recurse(String word, int start, int end, boolean affixed) {
        int wordLen = word.length();
        StringBuilder sb = new StringBuilder();
        char startChar = word.charAt(start);
        char endChar = word.charAt(end);

        if ((end - start) <= 1) {
            if (end == start && !affixed) {
                word = sb.append(word.substring(0, start + 1) + word.charAt(start) + word.substring(start + 1, wordLen)).toString();
            } else if (!affixed) {
                // Means that it is even so must add a random digit in middle
                word = sb.append(word.substring(0, start + 1) + "x" + word.substring(start + 1, wordLen)).toString();
            }
            return word;
        }
        if (affixed && !(startChar == endChar)) {
            return "NA";
        }
        String result = "NA";

        if (startChar == endChar) {
            result = recurse(word, start + 1, end - 1, affixed);
        }

        if ((result.equals("NA") || word.equals(result)) && startChar == word.charAt(end - 1)) {
            result = recurse(word.substring(0, start) + endChar + word.substring(start, wordLen),
                    start + 1, end, true);
        }

        if ((result.equals("NA") || word.equals(result)) && word.charAt(start + 1) == endChar) {
            result = recurse(word.substring(0, end + 1) + startChar + word.substring(end + 1, wordLen),
                    start + 1, end, true);
        }

        return result;
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public String findPalindrome(String argument)
    {
        StringBuilder arg = new StringBuilder(argument);
        StringBuilder value = new StringBuilder(argument);
        arg = arg.reverse();
        int length = arg.length();
        boolean flag = false, found = false;
        for(int i = 0; i < length; i ++)
        {
            if(value.charAt(i) == arg.charAt(i))
            {
                if(i == length - 1)
                    found = true;
                continue;
            }
            else if(!flag)
            {
                if(arg.charAt(i) == arg.charAt(length - i - 2))
                {
                    arg.insert(i, value.charAt(i));
                    value.insert(length - i, value.charAt(i));
                }
                else
                {
                    value.insert(i, arg.charAt(i));
                    arg.insert(length - i, arg.charAt(i));
                }
                flag = true;
            }
            else
            {
                found = false;
                break;
            }
        }
        if(!flag)
        {
            if(length == 1)
            {
                value.insert(0, value.charAt(0));
            }
            else if(length % 2 == 0)
                value.insert(length / 2, 'a');
            else
            {
                value.insert(length / 2 + 1, value.charAt(length / 2));
            }
        }
        if(found)
            return value.toString();
        else
            return "NA";
    }
    public static void main(String[] args) throws IOException{
        Main main = new Main();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String argument;
        argument = br.readLine();
        br.close();
        String palindrome = main.findPalindrome(argument);
        System.out.println(palindrome);
    }
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package ba7s;

import java.util.Scanner;

/**
 *
 * @author marten
 */
public class Ba7s {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner f=new Scanner (System.in);
        String s=f.next();
        int x=s.length();
        int m ,w=0;
        char[]c=new char[x+1];
        for(int i=0;i<x;i++){
          c[i]=s.charAt(i);
        }
        if(x%2==0){
           m=x/2;
        }else{
          m=(x+1)/2;
        }
          if(x==1)
               c[1]=c[0];
              for(int i=0;i<m;i++){
               for(int j=(m-1);j<x;j++){
                   if(s.charAt(i)==s.charAt(j)){
                         w++;
                         break;
                   }
               }
           }
                if(w<(m-1)){
             System.out.print("NA");
          }else{
        for(int i=0,k=(x-1);i<(m-1);i++,k--){
                 if(c[i]!=c[k]&&c[i]!=c[k-1]){
                    for(int j=0,n=x;j<m;j++,n--){
                        c[n]=c[i];
                         // System.out.print("first half");
                    }
                 }
        }
        for(int i=0,k=(x-1);i<(m-1);i++,k--){
             if(c[k]!=c[i]&&c[k]!=c[i+1]){
                 for(int e=x;e>0;e--){
                  c[e]=c[e-1];
                 }
                 for(int j=0,n=x;j<m;j++,n--){
                     c[j]=c[n];
                   // System.out.print("second half");
                  }
             }
        }
              if(c[m-1]==c[m]){
             c[m]='w';
             for(int j=0,n=x;j<m;j++,n--){
                   c[n]=c[j];
              //System.out.print("i will add letter");
             }
         }else{
            for(int j=0,n=x;j<m;j++,n--){
               c[n]=c[j];
                // System.out.print("half");
            }
          }
       for(int i=0;i<(x+1);i++){
         System.out.print(c[i]);
       }
    }
  }
}

import java.util.*;

public class Main
{
	public static void main(String[] args)
	{

		// 451B 526A 439B
		Scanner s = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		sb.append(s.next());
		int len = sb.length();
		StringBuilder temp;

		for (int i = 0;i < len;i++)
		{
			for (char ch = 'a';ch <= 'z';ch++)
			{
				temp = new StringBuilder();
				temp.append(sb);
				if (isPalindrome(temp.insert(i, ch), len + 1))
				{
					System.out.println(temp);
					return;
				}

			}
		}

		System.out.println("NA");

	}

	public static boolean isPalindrome(StringBuilder sb, int len)
	{

		int half = len / 2;

		for (int i = 0;i < half;i++)
			if (sb.charAt(i) != sb.charAt(len - i - 1))
				return false;

		return true;
	}
}

import java.util.Scanner;
public class KitayutaSGift {
public static void main(String[] args) {
     Scanner input=new Scanner(System.in);
     String s=input.next();
     int beg=0;
     int end=s.length()-1;
     int f=0;
     while(beg<=end){
         if(s.charAt(beg)!=s.charAt(end)){
           if(f!=1){
           if(s.charAt(beg+1)==s.charAt(end)||s.charAt(end-1)==s.charAt(beg)){
            if(s.charAt(end-1)==s.charAt(beg)){
                  s=s.substring(0,beg)+s.charAt(end)+s.substring(beg,s.length());
                 beg++;}
            else
               s=s.substring(0,end+1)+s.charAt(beg++)+s.substring(end+1,s.length());

             }
           f=1;
           }
           else{
                System.out.println("NA");
                f=2;
                break;
             }
           }
        else{
             beg++;
             end--;
          }
       }
     if(f==1)
         System.out.println(s);
     else if(f==0){
      if(s.length()%2==0)
         s=s.substring(0,s.length()/2)+s.substring(s.length()/2-1,s.length());

     else
         s=s.substring(0, s.length()/2+1)+s.substring(s.length()/2,s.length());

         System.out.println(s);
     }
}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        int mid = (input.length())/2;
        boolean check = true;
        boolean global = false;
        boolean before = false;
        for (int i = 0 ; i < mid ; i++) {
            if (input.charAt(i) != input.charAt(input.length() - i - 1)) {
                check = false;
                break;
            }
        }
        if (check) {
            global = true;
            for (int i = 0 ; i < input.length() ; i++) {
                if (i == mid)
                    System.out.print(input.charAt(i) + "" + input.charAt(i));
                else
                    System.out.print(input.charAt(i));
            }
        }
        else {
            for (int i = 0 ; i < mid  && !before ; i++) {
                if (input.charAt(i) != input.charAt(input.length() - i - 1)) {
                    boolean temp = true;
                    for (int j = i + 1 ; j < mid; j++) {
                        if (input.charAt(j) != input.charAt(input.length() - j)) {
                            temp = false;
                            before = true;
                            break;
                        }
                    }
                    if (temp) {
                        global = true;
                        for(int j = 0 ; j < input.length() ; j++) {
                            if (j == input.length() - i - 1) {
                                System.out.print(input.charAt(j) + "" + input.charAt(i));
                            }
                            else
                                System.out.print(input.charAt(j));
                        }
                        break;
                    }
                }
            }
        }
        if (!global)
            System.out.println("NA");
    }
}

import java.util.Scanner;
public class MrKitayutaSGift
{

    public static void main(String[] args)
    {
       Scanner in = new Scanner (System.in);
       String s = in.next();

       if (s.length()==1)
           System.out.println(s+s);
       else if (palindroom(s)&&s.length()%2==0)
       {
           System.out.println(s.subSequence(0, s.length()/2)+"a"+s.subSequence(0, s.length()/2));
       }
        else
       {

           int i=0;
           int j=0;
           int counter=0;
           int div = s.length()/2;
           String fristHalf = s.substring(0, div);
           String secHalf=s.substring(div+1);
           i=fristHalf.length()-1;
           while (j<secHalf.length())
           {
                if (fristHalf.charAt(i)==secHalf.charAt(j))
                 {
                    counter++;
                 }
                 j++;
                i--;
           }
           if (counter+1==div)
           {
               System.out.println(s+s.charAt(0));
           }

           else
               System.out.println("NA");
       }

    }
    public static boolean palindroom (String s)
    {
        int i=s.length();
        String palind="";
        while (i>0)
        {
            palind += s.substring(i-1,i);
            i--;
        }
        if (s.equals(palind))
            return true;
        else
            return false;
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public String findPalindrome(String argument)
    {
        StringBuilder arg = new StringBuilder(argument);
        StringBuilder value = new StringBuilder(argument);
        arg = arg.reverse();
        int length = arg.length();
        boolean flag = false, found = false;
        for(int i = 0; i < length; i ++)
        {
            if(value.charAt(i) == arg.charAt(i))
            {
                if(i == length - 1)
                    found = true;
                continue;
            }
            else if(!flag)
            {
                arg.insert(i, value.charAt(i));
                value.insert(length - i, value.charAt(i));
                flag = true;
            }
            else
            {
                found = false;
            }
        }
        if(!flag)
        {
            if(length % 2 == 0)
                value.insert(length / 2, 'a');
            else
            {
                value.insert(0, "a");
                value.insert(length, "a");
            }
        }
        if(found)
            return value.toString();
        else
            return "NA";
    }
    public static void main(String[] args) throws IOException{
        Main main = new Main();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String argument;
        argument = br.readLine();
        br.close();
        String palindrome = main.findPalindrome(argument);
        System.out.println(palindrome);
    }
}

import java.util.*;
public class MrKitayutaSGift {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int mean=0;
        for(int i=0; i < s.length();i++){
        mean +=i;
    }
        if(p0(s).length()>0){
           StringBuilder x =p0(s).insert(mean/(p0(s).length()), 'a');
            System.out.println(x);
        }else
        if(rp(s).length()>0){System.out.println(rp(s));}else{
            System.out.println("NA");
        }

    }
    static StringBuilder p0(String s){
        int c=0;
        StringBuilder sb0 = new StringBuilder(s).reverse();
        for(int i=0;i<sb0.length();i++){
            if(sb0.charAt(i)==s.charAt(i)){
                c++;
            }
        }
        if(c==sb0.length()){
            return new StringBuilder(s);
        }else{
            return new StringBuilder();
        }
    }
    static boolean p(String s){
        int c=0;
        StringBuilder sb0 = new StringBuilder(s).reverse();
        for(int i=0;i<sb0.length();i++){
            if(sb0.charAt(i)==s.charAt(i)){
                c++;
            }
        }
        if(c==sb0.length()){
            return true;
        }else{
            return false;
        }
    }
    static StringBuilder rp(String s){
        String ns ="";
        StringBuilder sb = new StringBuilder(s);
        int count=0;
        //StringBuilder space =new StringBuilder("");

        //sb.insert(sb.length(), ' ');
        for(int i =s.length();i>=0;i--){
           for(char c='a';c<='z';c++){
           //space.append(c);
           sb.insert(i, c);
           ns=sb.toString();
           if(p(ns)){
                count++;
                break;
            }else{
               sb.deleteCharAt(i);
           }
           }
           if(p(ns)){

                break;
            }

        }
        if(count >0){
            return sb;
        }else{
            return new StringBuilder();
        }
    }

}

import java.io.*;

public class A {
	public static void main(String[] args) throws Exception {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));

		String s = r.readLine();

		String a = s + s.charAt(0);
		String b = s.charAt(s.length() - 1) + s;

		StringBuffer sb;

		if(new StringBuffer(a).reverse().toString().equals(a))	{
			System.out.println(a);
			return;
		}

		if(new StringBuffer(b).reverse().toString().equals(b)) {
			System.out.println(b);
			return;
		}

		for(int i=1;i<s.length()-1;i++) {
			sb = new StringBuffer(s);
			sb.insert(i, s.charAt(s.length() - 1 - i));
			if(sb.toString().equals(sb.reverse().toString())) {
				System.out.println(sb.toString());
				return;
			}
		}

		System.out.println("NA");
	}
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

      //  package ba7s;

import java.util.Scanner;

/**
 *
 * @author marten
 */
public class Ba7s {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner f=new Scanner (System.in);
        String s=f.next();
        int x=s.length();
        int m ,w=0;
        char[]c=new char[x+1];
        for(int i=0;i<x;i++){
          c[i]=s.charAt(i);
        }
        if(x%2==0){
           m=x/2;
        }else{
          m=(x+1)/2;
        }
          if(x==1)
               c[1]=c[0];
              for(int i=0;i<=m;i++){
               for(int j=m;j<x;j++){
                   if(s.charAt(i)==s.charAt(j)){
                         w++;
                 // System.out.print(s.charAt(i));
                         break;
                   }
               }
           }
             // System.out.print(w + ""+m);
             // for(int i=x;i>m)
                if(w<(m)){
             System.out.print("NA");
          }else{
        for(int i=0,k=(x-1);i<(m-1);i++,k--){
                 if(c[i]!=c[k]&&c[i]!=c[k-1]){
                    for(int j=0,n=x;j<m;j++,n--){
                        c[n]=c[j];
                         // System.out.print("first half");
                    }
                 }
        }
        for(int i=0,k=(x-1);i<(m-1);i++,k--){
             if(c[k]!=c[i]&&c[k]!=c[i+1]){
                 for(int e=x;e>0;e--){
                  c[e]=c[e-1];
                 }
                 for(int j=0,n=x;j<m;j++,n--){
                     c[j]=c[n];
                   // System.out.print("second half");
                  }
             }
        }
              if(c[m-1]==c[m]){
             c[m]='w';
             for(int j=0,n=x;j<m;j++,n--){
                   c[n]=c[j];
              //System.out.print("i will add letter");
             }
         }else{
            for(int j=0,n=x;j<m;j++,n--){
               c[n]=c[j];
                // System.out.print("half");
            }
          }
       for(int i=0;i<(x+1);i++){
         System.out.print(c[i]);
       }
    }
  }
}

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner input = new Scanner (System.in);

       while(input.hasNext()){
       String s = input.next();

       if (s.length() == 1) {System.out.println(s+s); continue ;}
       String r ="";
       if (s.equals(m(s))){

           for (int i = 0 ; i<s.length() ; i++){if (i == s.length()/2){r+=s.charAt(i);}r+=s.charAt(i); }

       }

       else {
       if ((s+s.charAt(0)).equals(m(s+s.charAt(0)))) r = (s+s.charAt(0));
       else if ((s.charAt(s.length()-1)+s).equals(m((s.charAt(s.length()-1)+s)))) r = (s.charAt(s.length()-1)+s) ;
       else if (m2(s))continue;
       else r = "NA";
       }
       System.out.println(r);
       }
    }
    public static String m (String x){
    String r =""; char[]arr = x.toCharArray();
    for (int i = x.length()-1 ; i >= 0 ; i--) r +=arr[i];
    return r ;
    }
    public static boolean m2 (String x){
      String r ="";
    for (int i = 0 ; i < x.length() ; i++) {
    r = x.substring(0,x.length()-i) +x.charAt(i)+x.substring(x.length()-i, x.length());
    if (r.equals(m(r))){System.out.println(r); return true  ;}

    }
    return false ;
    }

}

import java.util.Scanner;

public class snk11 {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int len = s.length();
		boolean res = false;
		for (int i = 0; i < s.length(); i++) {
			char t = s.charAt(len - i - 1);
			String r = s.substring(0, i) + t + s.substring(i);
		//	System.out.println(t + " " + r);
			if (r.equals(new StringBuilder(r).reverse().toString())) {
				res = true;
				System.out.println(r);
			}

		}
		if (!res) {
			for (int i = 0; i < s.length(); i++) {
				char t = s.charAt(i);
				String r = s.substring(0, len - i) + t + s.substring(len - i);
			//	System.out.println(t + " " + r);
				if (r.equals(new StringBuilder(r).reverse().toString())) {
					res = true;
					System.out.println(r);
					break;
				}

			}

		}
		if (!res)
			System.out.println("NA");
	}

}

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * Created by kgribov on 18/01/15.
 */
public class A {
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        String st = reader.readLine();

        int insertPos = -1;
        char ch = 'a';

        int indexF = 0;
        int indexS = st.length() - 1;

        while (indexF <= indexS){
            char fChar = st.charAt(indexF);
            char sChar = st.charAt(indexS);

            if (fChar == sChar) {
                indexF++;
                indexS--;
            } else {
                if (insertPos < 0) {
                    ch = fChar;
                    insertPos = indexS;

                    indexF++;
                } else {
                    System.out.println("NA");
                    return;
                }
            }
        }

        if (insertPos < 0) {
            ch = st.charAt(indexF - 1);
            insertPos = indexF - 1;
        }

        String st1 = st.substring(0, insertPos + 1);
        String st2 = st.substring(insertPos + 1, st.length());

        System.out.println(st1 + new String(new char[]{ch}) + st2);

        reader.close();
    }
}

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        String n = in.next();

        char[] chars;

        chars = n.toCharArray();
        int m = chars.length;

        for (int i = 0; i < chars.length; i++) {

            if (chars[i] == chars[m - 1]) {
                m--;

            } else {
                chars[m - 1] = chars[i];
                m--;
            }

        }
        int r = 0;
        if (chars.length %2 == 0) {
            for (int h = 0; h < chars.length / 2; h++) {
                System.out.print(chars[h]);
            }
            System.out.print("h");
            for (int d = chars.length-1; d >= chars.length / 2; d--) {
                System.out.println(chars[d]);
            }

        } else {
            System.out.println(chars);
        }
    }

}

//package code;

import java.util.Scanner;

public class dab {

	public static boolean check(String s){

		StringBuilder temp=new StringBuilder(s).reverse();

		return temp.toString().equals(s);
	}

	public static void main(String args[]){

		Scanner in=new Scanner (System.in);
		String S=in.nextLine();
		String temp="";

		if(S.length()==1){
			System.out.println(S+S);
			return;
		}
		else if(check(S)&&S.length()%2!=0){
			System.out.println("NA");
			return;
		}
		else if (check(S)&&S.length()%2==0){
			S=S.substring(0, S.length()/2)+"a"+S.substring(S.length()/2);
			System.out.println(S);
			return;
		}
		else
		{
			for(int i=97;i<123;i++){
				temp=(char)i+S;
				if(check(temp)){
					System.out.println(temp);
					return ;
				}
			}
			for(int a=1;a<S.length()+1;a++){
				for(int i=97;i<123;i++){
					temp=S.substring(0,a)+(char)i+S.substring(a);
					if(check(temp)){
						System.out.println(temp);
						return ;
					}
				}
			}

		}
		System.out.println("NA");

	}
}

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String word = sc.nextLine();

        if (word.length() == 1){
            System.out.println(word+word);
            return;
        }
        if (isPalindrome(word)){
            System.out.println(word);
            return;
        }
        int len = word.length();

        String letter = Character.toString(word.charAt(0));
        String strbuf = word;
        for (int i = 0; i <= word.length(); i++) {
            strbuf = new StringBuilder(strbuf).insert(len - i, letter).toString();
            if (isPalindrome(strbuf)) {
//                System.out.println(strbuf);
                return;
            }

//            System.out.println("I IS AT:::::" + (i+1) + "   LENGTH IS " + word.length());
            if (i==word.length()){
                letter = Character.toString(word.charAt(i-1));
            } else{
                letter = Character.toString(word.charAt(i));
            }

//            letter = "#";
//            System.out.println("letter: " + letter + " i: " + i);
            System.out.println(strbuf);
            strbuf = word;

        }
        System.out.println("NA");
    }

    public static boolean isPalindrome(String str) {
        int len = str.length() - 1;
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) != str.charAt(len)) {
                return false;
            }
            len--;
        }
        return true;
    }
}

import java.util.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		String s = new String();
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()){
			s = cin.next();
			int len = s.length();
			int res = -1;
			for(int i = 0 ; i < (len + 1) / 2 ; i ++){
				int l = 0 ,r = len - 1;
				int tres = 1;
				while(l <= r){
					if(l == i){
						l ++;
						continue;
					}
					if(s.charAt(l) != s.charAt(r)) tres = 0;
					l ++;r --;
				}
				if(tres == 1) res = i;
			}
			if(len == 1) System.out.println(s + s);
			else if(res == -1) System.out.println("NA");
			else{
				for(int i = 0 ; i < (len + 1) / 2 ; i ++)
					System.out.print(s.charAt(i));
				if(len % 2 == 0) System.out.print(s.charAt(len / 2));
				for(int i = (len + 1) / 2 - 1 ; i >= 0 ; i --)
					System.out.print(s.charAt(i));
				System.out.println();
			}
		}
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        int mid = (input.length())/2;
        boolean check = true;
        boolean global = false;
        boolean before = false;
        for (int i = 0 ; i < mid ; i++) {
            if (input.charAt(i) != input.charAt(input.length() - i - 1)) {
                check = false;
                break;
            }
        }
        if (check) {
            global = true;
            for (int i = 0 ; i < input.length() ; i++) {
                if (i == mid)
                    System.out.print(input.charAt(i) + "" + input.charAt(i));
                else
                    System.out.print(input.charAt(i));
            }
        }
        else {
            for (int i = 0 ; i < mid  && !before ; i++) {
                if (input.charAt(i) != input.charAt(input.length() - i - 1)) {
                    boolean temp = true;
                    for (int j = i + 1 ; j < mid; j++) {
                        if (input.charAt(j) != input.charAt(input.length() - j)) {
                            temp = false;
                            before = true;
                            break;
                        }
                    }
                    if (temp) {
                        global = true;
                        for(int j = 0 ; j < input.length() ; j++) {
                            if (j == input.length() - i - 1) {
                                System.out.print(input.charAt(j) + "" + input.charAt(i));
                            }
                            else
                                System.out.print(input.charAt(j));
                        }
                        break;
                    }
                }
            }
        }
        if (!global) {
            boolean last = true;
            for (int i = 0 ; i < mid ; i++) {
                if (input.charAt(i) != input.charAt(input.length() - i - 2)) {
                    last = false;
                    break;
                }
            }
            if (last) {
                System.out.print(input.charAt(input.length() - 1) + "" + input);
            }
            else
                System.out.println("NA");
        }
    }
}

import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author angrySCV
 */
public class Main {
	public static void main (String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
	public void solve (int testNumber, Scanner in, PrintWriter out) {
		int incorrect = 0;
		String correctWord = "";
		String vvod = in.next();
		String secondTry = vvod;
		int dlinnaStroki = vvod.length();
		if (dlinnaStroki == 1) {
			System.out.print(vvod + vvod);
			return;
		}
		for (int i = 0; i < dlinnaStroki / 2; i++) {
			if (vvod.charAt(i) != vvod.charAt(dlinnaStroki - 1 - i)) {
				incorrect++;
				correctWord = vvod.substring(0, dlinnaStroki - i) + vvod.charAt(i) + vvod.substring(dlinnaStroki - i);
				vvod = correctWord;
				dlinnaStroki++;
			}

		}

		if (incorrect > 1) {
			incorrect = 0;
			dlinnaStroki = secondTry.length();
			for (int i = dlinnaStroki; i > dlinnaStroki / 2; i--) {
				if (secondTry.charAt(i - 1) != secondTry.charAt(dlinnaStroki - i)) {
					incorrect++;
					correctWord = secondTry.substring(0, dlinnaStroki - i) + secondTry.charAt(i - 1) + secondTry.substring(dlinnaStroki - i);
					secondTry = correctWord;
					dlinnaStroki++;
				}

			}
			vvod =secondTry;
		}

		switch (incorrect) {
			case 0:
				correctWord = vvod.substring(0, dlinnaStroki / 2) + vvod.charAt(dlinnaStroki / 2) + vvod.substring(dlinnaStroki / 2);
				System.out.println(correctWord);
				break;
			case 1:
				System.out.println(vvod);
				break;
			default:
				System.out.println("NA");
		}
	}
}

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String word = sc.nextLine();

        if (word.length() == 1){
            System.out.println(word+word);
            return;
        }

        //let's see the time difference with computing .length() every time and not
        int len = word.length();
        String strbuf = word;
        for (int i = 0; i <= word.length(); i++) {
            strbuf = new StringBuilder(strbuf).insert(word.length() - i, "r").toString();
            if (isPalindrome(strbuf)) {
                System.out.println(strbuf);
                return;
            }
            strbuf = word;
        }
        System.out.println("NA");
    }

    public static boolean isPalindrome(String str) {
        int len = str.length() - 1;
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) != str.charAt(len)) {
                return false;
            }
            len--;
        }
        return true;
    }
}

import java.util.Scanner;
public class main
{
    public static void main(String args[])
    {
        Scanner input = new Scanner(System.in);
        String x = input.nextLine();
        int n = x.length();
        char arr[] = new char[n];
        //System.out.println(isPallindrome(arr));
        for(int i=0;i<n;i++)
        {
            arr[i] = x.charAt(i);
        }
        if(isPallindrome(x))
        {
            if(n%2 != 0)
            {
                System.out.println(x.substring(0,n/2+1)+Character.toString(arr[n/2])+x.substring(n/2+1,n));
            }
            else
            {
                System.out.println(x.substring(0,n/2)+"y"+x.substring(n/2,n));
            }
            System.exit(0);
        }
        //System.out.println(isPallindrome(arr));
        int i=0;
        int j = n-1;
        int y = 0;
        String t = "";
        while(i <= j)
        {
            if(arr[i] != arr[j])
            {
                String l = x.substring(i,j+1);
                //System.out.println(l);
                l += Character.toString(arr[i]);
                //System.out.println(l);
                if(isPallindrome(l))
                {
                    y = 1;
                    System.out.println(t+l+t);
                    break;
                }
                String f = x.substring(i,j+1);
                //System.out.println(f);
                f = Character.toString(arr[j]) + f;
                //System.out.println(f);
                if(isPallindrome(f))
                {
                    y = 1;
                    System.out.println(t+f+t);
                    break;
                }
                break;
            }
            t += Character.toString(arr[i]);
            i++;
            j--;
        }
        if(y == 0)
        {
            System.out.println("NA");
        }
    }
    public static boolean isPallindrome(String z)
    {
        int n = z.length();
        char arr[] = new char[n];
        for(int i=0;i<n;i++)
                {
                        arr[i] = z.charAt(i);
                }
        //System.out.println(arr[0]);
        int i=0;
        int j = n-1;
        while(i<=j)
        {
            if(arr[i] != arr[j])
            {
//              System.out.println("Hello");
                return false;
            }
            i++;
            j--;
        }
        return true;
    }
}

public class Main
{
	public static void main(String[] args)
	{
		java.util.Scanner input = new java.util.Scanner(System.in);

		String s = input.next();
		int i = 0, j = 0;
		if(s.length() == 2)
		{
			System.out.println(s.charAt(0) + "" + 'y' + s.charAt(0));
			System.exit(0);
		}
		else if(s.length() == 1)
		{
			System.out.println(s.charAt(0) + "" + s.charAt(0));
			System.exit(0);
		}
		if(s.charAt(0) == s.charAt(s.length()-2))
		{
			System.out.println(s.charAt(s.length()-1) + "" + s);
			System.exit(0);
		}
		else if(s.charAt(1) == s.charAt(s.length()-1))
		{
			System.out.println(s + "" + s.charAt(0));
			System.exit(0);
		}
		if(s.length()%2 == 0)
		{
			i = s.length()/2 -1;
			j = s.length()/2 +1;
		}
		else
		{
			System.out.println("NA");
			System.exit(0);
		}
		int count = 0;
		int index = 0;
		char x = ' ';
		for( ; i>=0 && j<s.length() ; i--,j++)
		{
			if(s.charAt(i) == s.charAt(j))
				continue;
			else
			{
				if(s.charAt(i-1) == s.charAt(j) && i>0)
				{
					index = j;
					x = s.charAt(i);
					i--;
					count++;
				}
				else if(s.charAt(i) == s.charAt(j+1) && j<s.length()-2)
				{
					index = i+1;
					x = s.charAt(j);
					j++;
					count++;
				}
				else
				{
					System.out.println("NA");
					System.exit(0);
				}
			}
		}
		if(count > 1)
		{
			System.out.println("NA");
			System.exit(0);
		}
		System.out.println(s.substring(0,index) + x + s.substring(index));
	}
}

import java.util.Scanner;

/**
 *
 * @author mav3n
 */
public class A286 {

    public static boolean isPalindrome(String s){
        boolean rs = true;
        int l = s.length();
        for(int i=0;i<l/2;i++){
            if(s.charAt(i)==s.charAt(l-i-1)){
               continue;
            }
            rs=false;break;
        }
        return rs;
    }

    public static void main(String... arg){
                Scanner sc = new Scanner(System.in);
                String s = sc.nextLine();

                int l = s.length();

                boolean pl = isPalindrome(s);

                String result="";
                if(pl){
                    if(l%2==0){
                        result = s.substring(0, l/2)+"a"+s.substring(l/2, l);
                    }
                    else{
                        result = s.substring(0, l/2)+s.charAt(l/2)+s.substring(l/2, l);
                    }
                }else{
                 for(int i=0;i<l/2;i++){
                    if(s.charAt(i)==s.charAt(l-i-1)){
                        continue;
                    }
                    else{
                        if(s.charAt(i)==s.charAt(l-i-2)){
                            result=s.substring(0, i)+s.charAt(l-i-1)+s.substring(i, l);
                            if(!isPalindrome(result)){
                                result="NA";
                            }
                        }else if(s.charAt(i+1)==s.charAt(l-i-1)){
                            result=s.substring(0, l-i)+s.charAt(i)+s.substring(l-i, l);

                            if(!isPalindrome(result)){
                                result="NA";
                            }
                        }else{
                            result="NA";
                        }
                        break;
                    }
                }

                }
                System.out.println(result);
    }
}

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class palindrome
{
	static int inc=0;
	static boolean isPalindrome(String check)
	{
		String t="";
		for(int h=check.length()-1;h>=0;h--)
		{
			t=t.concat(Character.toString(check.charAt(h)));
		}
		//System.out.println(t+" "+check);
		if(t.equals(check))
		{
			inc++;
			//System.out.println(t+" "+check);
			//System.out.println("Check no.:"+ inc);
			return true;
		}
		else
		return false;
	}

	public static void main (String[] args) throws java.lang.Exception
	{
		String s;
		Scanner in = new Scanner(System.in);
		s=in.nextLine();
		int n=s.length();
		int i,j,flag=0,count=0;
		String m,se;
		String alpha="abcdefghijklmnopqrstuvwxyz";
			m=s;
			for(int o=0;o<alpha.length();o++)
			{
				String t="";
				t=Character.toString(alpha.charAt(o));
				//System.out.print(t);
				t=t.concat(m);
				//System.out.println(se);
				count++;
				if(isPalindrome(t))
				{
					flag=1;
					System.out.println(t);
					break;
				}
			}
			for(int o=0;o<alpha.length();o++)
			{
				String t="";
				t=Character.toString(alpha.charAt(o));
				m=m.concat(t);
				if(isPalindrome(m))
				{
					flag=1;
					System.out.println(m);
					break;
				}
			}
		if(flag==0)
		{
		for(i=0;i<n;i++)
		{
			m=s.substring(0,n-i);
			se=s.substring(n-i);

			for(int o=0;o<alpha.length();o++)
			{
				String t="",store;
				t=Character.toString(alpha.charAt(o));
				store=m;
				//System.out.print(m+" ");
				//System.out.print(t+" ");
				m=m.concat(t);
				m=m.concat(se);
				//System.out.println(se);
				if(isPalindrome(m))
				{
					System.out.println(m);
					flag=1;
					break;
				}
				m=store;
			}
			if(flag==1)
			break;
		}
		}
		if(flag==0)
		System.out.println("NA");
	}
}

import java.util.Scanner;
public class MyClass {

     public static boolean isPal(String str)
     {
         boolean result = true;
         for(int i= 0; i <= (str.length() -1)/2; i++)
         {
             if(str.charAt(i) != str.charAt(str.length()-1-i))
             {
                 result = false;
                 break;
             }
         }
         return result;
     }

     public static void main(String[] args) {
     Scanner scan = new Scanner(System.in);
     String str = scan.next();
     String result = "";

     if(str.length() ==1)
     {
         result = str + str;
     }
     else if(isPal(str))
     {
         if(str.length()%2 == 0)
         {
             result = str.substring(0, str.length()/2) + "a" + str.substring(str.length()/2);
         }
         else
             result = str.substring(0, str.length()/2 + 1) + str.substring(str.length()/2);
     }
     else if(str.length() == 2 && str.charAt(0) != str.charAt(1) )
         result = str +str.charAt(0) ;

     else
     {

         boolean done = false;
         int index  = 0;
         while(!done)
         {
             if(str.charAt(index) == str.charAt(str.length()-1-index))
             {
                 str= str.substring(1,str.length()-1);
                 index++;
             }
             else
                 done = true;
         }

         String str1 = str.substring(1);
         String str2 =str.substring(0,str.length()-1);
         if(isPal(str1))
         {
             result = str + str.charAt(0);
         }
         else if(isPal(str2))
         {
             result = str.charAt(str.length()-1) + str;
         }
         else
             result ="NA";

     }

     System.out.println(result);

   }
}

import java.util.*;
import java.io.*;

public class Palindrome
{
    public static void main(String args[])
    {
        Scanner fin = new Scanner(System.in);
        String s = fin.nextLine();

        int length = s.length();
        int midpoint = length / 2;

        boolean charAdded = false;

        if(length > 1)
        {

            int i = 0;

            while(i < (midpoint))
            {
                char left = s.charAt(i);
                char right = s.charAt(length - i - 1);

                //System.out.println(left + " " + right + " " + i);
                //System.out.println(s);
                if(s.charAt(i) != s.charAt(length - i - 1))
                {
                      if (left == s.charAt(length - i - 2) && !charAdded)
                      {
                            s = new StringBuilder(s).insert(i, right).toString();
                            length = s.length();
                            midpoint = length/2;
                            charAdded = true;
                            //System.out.println(s);
                      }
                      else if(s.charAt(i+1) == right && !charAdded)
                      {
                            s = new StringBuilder(s).insert(length-i, left).toString();
                            length = s.length();
                            midpoint = length/2;
                            charAdded = true;
                            //System.out.println(s);
                      }

                      else
                      {
                            //System.out.println(left+ " " + right + " " + s.charAt(i+1) + " " +
                             //   s.charAt(length - i - 2) + " " + charAdded + " i = " + i);
                            s = "NA";
                            break;
                      }
                }

                ++i;
            }
        }
        else
        {
            s = s + s;
            charAdded = true;
        }

        if(!charAdded && !s.equals("NA"))
        {
            s = new StringBuilder(s).insert(midpoint, s.charAt(midpoint)).toString();
        }
        System.out.println(s);
    }
}

import java.util.Scanner;
public class Main {
public static void main(String[] args) {
     Scanner input=new Scanner(System.in);
     String s=input.next();
     String x="";
     for(int i=s.length()-1;i>=0;i--)
         x+=s.charAt(i);
     if(s.equals(x)){
         if(s.length()%2==0){
          StringBuilder z=new  StringBuilder(x);
          x=""+z.insert(s.length()/2,'y');
          }
         if(s.length()==1)
            x+=x;
         System.out.println(x);
     }
    else{
       int n=0;
        for(int i=0;i<s.length();i++)
           if(s.charAt(i)!=x.charAt(i)){
              StringBuilder z=new  StringBuilder(x);
              x=""+z.insert(i,s.charAt(i));
            n++;
            }
          if(n!=1)
             System.out.println("NA");
          else
              System.out.println(x);
       }
    }
}

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner (System.in);
       while(input.hasNext()){
       String s = input.next();
       String r ="";
       if (s.equals(m(s))){
       if (s.length() % 2 == 0)
           for (int i = 0 ; i<s.length() ; i++){if (i == s.length()/2){r+="a";}r+=s.charAt(i); }
       else r = "NA";
       }
       else {
       if ((s+s.charAt(0)).equals(m(s+s.charAt(0)))) r = (s+s.charAt(0));
       else if ((s.charAt(s.length()-1)+s).equals(m((s.charAt(s.length()-1)+s)))) r = (s.charAt(s.length()-1)+s) ;
       else r = "NA";
       }
       System.out.println(r);
       }
    }
    public static String m (String x){
    String r =""; char[]arr = x.toCharArray();
    for (int i = x.length()-1 ; i >= 0 ; i--) r +=arr[i];
    return r ;
    }

}

import java.util.*;
public class Main
{
	public static void main(String[]args)
	{
		Scanner input=new Scanner (System.in);
		while(input.hasNext())
		{
			String s=input.nextLine(),a="";
			int x=0,y=0,n=s.length();
			boolean b=true;
			if(s.charAt(0)==s.charAt(s.length()-1))
			{
				for(x=0;x<s.length()/2;x++)
					if(s.charAt(x)!=s.charAt(s.length()-x-1))
						{
							b=false;
							y=x;
							break;
						}
				if(b)
					System.out.println(s.substring(0,(int)Math.ceil(s.length()/2.0))+s.charAt(s.length()/2)+s.substring((int)Math.ceil(s.length()/2.0),s.length()));
				else
				{
					b=true;
					a=s.substring(0,y)+s.charAt(n-y-1)+s.substring(y,n);
					for(x=0;x<a.length()/2;x++)
						if(a.charAt(x)!=a.charAt(a.length()-x-1))
						{
							b=false;
							break;
						}
					if(!b)
					{
						b=true;
						a=s.substring(0,n-y)+s.charAt(y)+s.substring(n-y,n);
						for(x=0;x<a.length()/2;x++)
							if(a.charAt(x)!=a.charAt(a.length()-x-1))
							{
								b=false;
								break;
							}
					}
					if(b)
						System.out.println(a);
				}
			}
			else if(s.charAt(0)==s.charAt(s.length()-2))
			{
				for(x=0;x<(s.length()-1)/2;x++)
					if(s.charAt(x)!=s.charAt(s.length()-x-2))
						b=false;
				if(b)
					System.out.println(s.charAt(s.length()-1)+s);
			}
			else if(s.charAt(1)==s.charAt(s.length()-1))
			{
				for(x=1;x<(s.length()+1)/2;x++)
					if(s.charAt(x)!=s.charAt(s.length()-x))
						b=false;
				if(b)
					System.out.println(s+s.charAt(0));
			}
			else
				System.out.println("NA");
			if(!b)
				System.out.println("NA");
		}
	}
}

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;

// this is not good for reading double values.
public class Problem5050A {
	static long m = 100000007;

	public static void main(String[] args) throws IOException {
		Reader r = new Reader();
		PrintWriter o = new PrintWriter(System.out, false);
		String s = r.readString();
		int count = 0;
		int j = s.length() - 1;
		boolean flag = false;
		String ans = "";
		for (int i = 0; i < s.length() / 2; i++) {
			if (s.charAt(i) != s.charAt(j)) {
				count++;
				if (count >= 2) {
					flag = true;
					break;
				}
				ans += s.substring(0, j + 1);
				ans += s.charAt(i);
				ans += s.substring(j + 1, s.length());
			} else {
				j--;
			}
		}
		if (count == 0) {
			s = s.substring(0, s.length() / 2) + "a" + s.substring(s.length() / 2);
			ans = s;
		}
		if (flag) {
			o.println("NA");
		} else {
			o.println(ans);
		}
		o.close();
	}

	// pair object x,y
	static class pair {
		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + x;
			result = prime * result + y;
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			pair other = (pair) obj;
			if (x != other.x)
				return false;
			if (y != other.y)
				return false;
			return true;
		}

		int x, y;

		public pair(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}

	public static long gcd(long a, long b) {
		a = Math.abs(a);
		b = Math.abs(b);
		while (b != 0) {
			long temp = a % b;
			a = b;
			b = temp;
		}
		return a;
	}

	public static int gcd(int a, int b) {
		a = Math.abs(a);
		b = Math.abs(b);
		while (b != 0) {
			int temp = a % b;
			a = b;
			b = temp;
		}
		return a;
	}

	static long[][] modPow(long[][] M, long exp) {
		long[][] result = new long[][] { { 1, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 } };
		long[][] pow = M;
		while (exp != 0) {
			if ((exp & 1) == 1) {
				result = multiply(result, pow);
			}
			exp >>>= 1;
			pow = multiply(pow, pow);
		}
		return result;
	}

	static long[][] multiply(long[][] A, long[][] B) {
		long[][] C = new long[4][4];
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				long value = 0;
				for (int k = 0; k < 4; k++) {
					value += A[i][k] * B[k][j];
				}
				C[i][j] = value % m;
			}
		}
		return C;
	}

	// input/output
	static class Reader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public Reader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public final String readString() throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.append((char) c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (c == '.')
				while ((c = read()) >= '0' && c <= '9')
					ret += (c - '0') / (div *= 10);
			if (neg)
				return -ret;
			return ret;
		}

		public int[] readIntArray(int size) throws IOException {
			int[] arr = new int[size];
			for (int i = 0; i < size; i++)
				arr[i] = nextInt();
			return arr;
		}

		public long[] readLongArray(int size) throws IOException {
			long[] arr = new long[size];
			for (int i = 0; i < size; i++)
				arr[i] = nextLong();
			return arr;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}
	}
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class TA {

	public static void main(String[] args) {
		FastScanner in=new FastScanner();
		char[] s=in.nextToken().toCharArray();
		int n=s.length;
		char[] res=new char[n+1];
		res[n/2]='a';
		if(check(0, n-1, s, 0, n, res, true))
			System.out.println(String.valueOf(res));
		else
			System.out.println("NA");

	}
	static boolean check(int i,int j,char[] s,int ii,int jj,char[] res,boolean ff){
		if(i>j){
			return ff;
		}
		boolean f=false;
		if(s[i]==s[j]){
			res[ii++]=s[i++];
			res[jj--]=s[j--];
			f=check(i, j, s, ii, jj, res,ff);
			if(!f){
				ii--;
				jj++;
			}else{
				return f;
			}
		}else{
			if(s[i+1]==s[j]||s[i]==s[j-1]){
				res[ii++]=s[j];
				res[jj--]=s[j];
				j--;
				f=check(i, j, s, ii, jj, res,ff);
				if(!f){
					ii--;
					jj++;
					j++;
				}else{
					return f;
				}

				res[ii++]=s[i];
				res[jj--]=s[i];
				i++;
				f=check(i, j, s, ii, jj, res,ff);
				if(!f){
					ii--;
					jj++;
					i--;
				}else{
					return f;
				}
			}
		}
		return f;
	}
	static class FastScanner{
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(){br=new BufferedReader(new InputStreamReader(System.in));}
		String nextToken(){
			while(st==null||!st.hasMoreElements())
				try{st=new StringTokenizer(br.readLine());}catch(Exception e){}
			return st.nextToken();
		}
		int nextInt(){return Integer.parseInt(nextToken());}
		long nextLong(){return Long.parseLong(nextToken());}
		double nextDouble(){return Double.parseDouble(nextToken());}
	}

}

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.concurrent.LinkedBlockingDeque;

import javax.swing.border.Border;

public class a {

	public static long mod = (long) Math.pow(10, 9) + 7;
	public static int k = 0;

	private static class node {
		long num;
		int k;
		int index;

		node(long m, int k, int index) {
			num = m;
			this.k = k;
			this.index = index;
		}

	}

	public static class point implements Comparable<point> {
		long x;
		long y;
		long b;

		point(long x, long y, long b) {
			this.x = x;
			this.y = y;
			this.b = b;
		}

		@Override
		public int compareTo(point o) {
			if (k == 0)
				return (int) (o.x - x);
			else
				return (int) (y - o.y);

		}
	}

	public static int ch(long y) {
		int r = Long.bitCount(y);
		return r;
	}

	public static long gcd(long x, long y) {
		if (y == 0)
			return x;

		return gcd(y, x % y);
	}

	public static boolean ch[] = new boolean[10000005];
	public static ArrayList<Integer> prime = new ArrayList();

	// public static Queue<Integer> pp;

	public static void sieve(int k) {
		ch[0] = ch[1] = true;

		for (int i = 2; i <= k; i++) {
			if (!ch[i]) {
				prime.add(i);
				// pp.add(i);
				for (long j = (long) i * (long) i; j <= k; j += i) {
					ch[(int) j] = true;
				}
			}
		}

	}

	public static long pw(int x, int power, int mod) {
		if (power == 1)
			return x % mod;
		else if (power % 2 == 0)
			return pw((x % mod * x % mod) % mod, power / 2, mod);
		else
			return (pw(x, power - 1, mod) % mod * x % mod) % mod;

	}

	public static int solve(String y) {
		int p1 = y.length() - 1;
		int c1 = 0;
		int index = 0;
		int rr = y.length() / 2;
		for (int i = 0; i < rr; i++) {
			if (i == y.length())
				break;
			// System.out.println(y.charAt(i));
			if (y.charAt(i) != y.charAt(p1)) {
				c1++;
				index = p1;
				rr++;

			} else {
				p1--;
			}

		}
		return c1;
	}

	public static int solve2(String y) {
		int p1 = y.length() - 1;
		int c1 = 0;
		int index = 0;
		for (int i = 0; i < y.length() / 2; i++) {
			if (y.charAt(i) != y.charAt(p1)) {
				c1++;
				index = p1 + 1;

			} else {
				p1--;
			}

		}
		return index;
	}

	public static char solve3(String y) {
		int p1 = y.length() - 1;
		int c1 = 0;
		int index = 0;
		char a = 'a';
		for (int i = 0; i < y.length() / 2; i++) {
			if (y.charAt(i) != y.charAt(p1)) {
				c1++;
				index = p1 + 1;
				a = y.charAt(i);

			} else {
				p1--;
			}

		}
		return a;
	}

	public static int solve4(String y) {
		int p1 = y.length() - 1;
		int c1 = 0;
		int index = 0;
		int rr = y.length() / 2;
		for (int i = 0; i < rr; i++) {
			if (i == y.length())
				break;
			if (y.charAt(i) != y.charAt(p1)) {
				c1++;
				index = p1;
				i--;
				rr++;

			}

			p1--;
			if (i < -1 || p1 < 0) {
				c1 = 5;
				break;
			}
		}
		return c1;
	}

	public static int solve5(String y) {
		int p1 = y.length() - 1;
		int c1 = 0;
		int index = 0;
		for (int i = 0; i < y.length() / 2; i++) {
			if (y.charAt(i) != y.charAt(p1)) {
				c1++;
				index = i;
				i--;

			}
			p1--;

		}
		return index;
	}

	public static char solve6(String y) {
		int p1 = y.length() - 1;
		int c1 = 0;
		int index = 0;
		char a = 'a';
		for (int i = 0; i < y.length() / 2; i++) {
			if (y.charAt(i) != y.charAt(p1)) {
				c1++;
				a = y.charAt(p1);
				i--;

			}
			p1--;

		}
		return a;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		// BufferedReader in = new BufferedReader(new FileReader(
		// "in.txt"));
		StringBuilder qq = new StringBuilder();
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
		// PrintWriter out = new PrintWriter(new FileWriter("out.txt"));

		// int n = Integer.parseInt(in.readLine());
		// String y[] = in.readLine().split(" ");
		// int a[] = new int[n];
		// for (int i = 0; i < n; i++) {
		// a[i] = Integer.parseInt(y[i]);
		// }
		String y = in.readLine();

		int c1 = solve(y);
		int c2 = solve4(y);
		// System.out.println(c1 + " " + c2);
		if (c1 == 0) {
			if (y.length() % 2 == 0) {
				for (int i = 0; i < y.length() / 2; i++) {
					out.print(y.charAt(i));
				}
				out.print("a");
				for (int i = y.length() / 2; i < y.length(); i++) {
					out.print(y.charAt(i));
				}
			} else {
				for (int i = 0; i < y.length() / 2; i++) {
					out.print(y.charAt(i));
				}
				out.print(y.charAt(y.length() / 2));
				for (int i = y.length() / 2; i < y.length(); i++) {
					out.print(y.charAt(i));
				}
			}
		} else if (c1 == 1) {

			char ans[] = new char[y.length() + 1];
			int indx = solve2(y);
			char k = solve3(y);
			int p = 0;
			for (int i = 0; i < y.length() + 1; i++) {
				if (i == indx) {
					ans[i] = k;
					continue;
				}
				ans[i] = y.charAt(p);
				p++;

			}

			for (int i = 0; i < ans.length; i++) {
				out.print(ans[i]);
			}
		} else if (c2 == 1) {
			// System.out.println("A");
			char ans[] = new char[y.length() + 1];
			int indx = solve5(y);
			char k = solve6(y);
			int p = 0;
			for (int i = 0; i < y.length() + 1; i++) {
				if (i == indx) {
					ans[i] = k;
					continue;
				}
				ans[i] = y.charAt(p);
				p++;

			}
			for (int i = 0; i < ans.length; i++) {
				out.print(ans[i]);
			}

		} else {
			System.out.println("NA");
		}
		out.close();

	}
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class codeforces_a_505 {

    static class FastScanner{
        BufferedReader s;
        StringTokenizer st;

        public FastScanner(){
            st = new StringTokenizer("");
            s = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastScanner(File f) throws FileNotFoundException{
            st = new StringTokenizer("");
            s = new BufferedReader (new FileReader(f));
        }

        public int nextInt() throws IOException{
            if(st.hasMoreTokens())
                return Integer.parseInt(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextInt();
            }
        }

      public double nextDouble() throws IOException{
            if(st.hasMoreTokens())
                return Double.parseDouble(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextDouble();
            }
        }

        public long nextLong() throws IOException{
            if(st.hasMoreTokens())
                return Long.parseLong(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextLong();
            }
        }

        public String nextString() throws IOException{
            if(st.hasMoreTokens())
                return st.nextToken();
            else{
                st = new StringTokenizer(s.readLine());
                return nextString();
            }

        }
        public String readLine() throws IOException{
            return s.readLine();
        }

        public void close() throws IOException{
            s.close();
        }

    }
      private static FastScanner s = new FastScanner();
      private static PrintWriter ww = new PrintWriter(new OutputStreamWriter(System.out));

      static int count=0;
     public static void main(String[] args) throws IOException
     {
        String ss = s.nextString();
        StringBuffer sd = new  StringBuffer(ss);
        String rev = sd.reverse().toString();
        if(pal(ss))
        {
            if(ss.length()%2==0)
            {   System.out.println(""+ss.substring(0,ss.length()/2)+"y"+ss.substring(ss.length()/2,ss.length()));
            }
            else
            {
                  sd.append(ss.charAt(0));
                  if(pal(sd.toString()))
                      System.out.println(""+sd.toString());
                  else
                      System.out.println("NA");

            }
        }
        else
        {
           String dg=mpal(ss);
            System.out.println("----> "+dg);
           if(pal(dg))
           {
               System.out.println("-->"+dg);
           }
           else
           {
               System.out.println("NA");
           }
        }

         s.close();
         ww.close();
     }
     public static boolean pal(String a)
     {
        StringBuffer sr = new StringBuffer(a);
        String rev = sr.reverse().toString();
        if(rev.equals(a))
            return true;
        else
            return false;
     }

        public static String mpal(String ss)
     {
        StringBuffer sr = new StringBuffer(ss);String ans="art";
        StringBuilder sb=new StringBuilder(ss);
        String rev = sr.reverse().toString();boolean arc=true;
        if(rev.charAt(0)!=ss.charAt(0))
        {
           sb.setCharAt(0,rev.charAt(0));
           ans=sb.toString();
            if(!pal(ans))
            {
                sb=new StringBuilder(ss);
                sb.append(ss.charAt(0));
                ans=sb.toString();
            }

        }
        else
        {
          for(int i=0;i<ss.length();i++)
          {
              if(ss.charAt(i)!=rev.charAt(i))
              {
                  sb.setCharAt(i,rev.charAt(i));break;
              }
          }
            ans=sb.toString();

        }
        return ans;
     }
        public static int gcd(int a, int b){
        return b == 0 ? a : gcd(b,a%b);
    }

}
/*zabardast swappimng of sorting
/*
    for(int h=0;h<n;h++)
        {  int temp,temp1,temp2;
             for(int y=h+1;y<n;y++)
           {
             if(a[y][2]>=a[h][2])
             {

             temp=a[y][2];                 //////sorting
             a[y][2]=a[h][2];
              a[h][2]=temp;
              temp1=a[y][0];
              a[y][0]=a[h][0];
              a[h][0]=temp1;
              temp2=a[y][1];
              a[y][1]=a[h][1];
              a[h][1]=temp2;

             }
           }
        }
*/
/*
static final Point getMinMax(int[] array) {
        int min = array[0];
        int max = array[0];

        for (int index = 0, size = array.length; index < size; ++index, ++index) {
            int value = array[index];

            if (index == size - 1) {
                min = min(min, value);
                max = max(max, value);
            } else {
                int otherValue = array[index + 1];

                if (value <= otherValue) {
                    min = min(min, value);
                    max = max(max, otherValue);
                } else {
                    min = min(min, otherValue);
                    max = max(max, value);
                }
            }
        }

        return new Point(min, max);
    }

*/
/*

/// Demonstrate several Is... methods.
class IsDemo {
public static void main(String args[]) {
char a[] = {'a', 'b', '5', '?', 'A', ' '};
for(int i=0; i<a.length; i++) {
if(Character.isDigit(a[i]))                                   ///check if digit is present in string
System.out.println(a[i] + " is a digit.");
if(Character.isLetter(a[i]))
    System.out.println(num + " in binary: " +
Integer.toBinaryString(num));
System.out.println(num + " in octal: " +
Integer.toOctalString(num));
System.out.println(num + " in hexadecimal: " +
Integer.toHexString(num));
}
}
*/
/*
private static void findSubsets(int array[])
{
  int numOfSubsets = 1 << array.length;

  for(int i = 0; i < numOfSubsets; i++)
 {
    int pos = array.length - 1;                                /////bitmask to find all sub sets
   int bitmask = i;

   System.out.print("{");
   while(bitmask > 0)
   {
    if((bitmask & 1) == 1)
     System.out.print(array[pos]+",");
    bitmask >>= 1;
    pos--;
   }
   System.out.print("}");
 }
}
*/

/*   no of DIVISORSSSSSS
 public ArrayList<Integer> get(int x){
            ArrayList<Integer> divisors = new ArrayList<>();
            for(int i = 1; i * i <= x; i++){
                if(x % i == 0){
                    divisors.add(i);
                    if(i * i != x){
                        divisors.add( x / i);
                    }
                }
            }

*/
/*  //// find sum of multiple of a value below limit// ----> (l*(n+1))/2
  public static long getSequenceSum(long value, long limit) {
long q = (limit - 1) / value;
long ans = ((value*q)*(1+q) )/ 2;
return ans;
}
*/
/*// largest prime factor of a no
 public static long largestPrimeFactor(long n) {

        // largest composite factor must be smaller than sqrt
        long sqrt = (long)Math.ceil(Math.sqrt((double)n));

        long largest = -1;

        for(long i = 2; i <= sqrt; i++) {
            if(n % i == 0) {
                long test = largestPrimeFactor(n/i);
                if(test > largest) {
                    largest = test;
                }
            }
        }

        if(largest != -1) {
            return largest;
        }

        // number is prime
        return n;
    }
*/
/*    // prime no using sieve of erostheneses
  public static void prime()
{
  boolean[] isPrime = new boolean[100000000+ 1];
         Arrays.fill(isPrime, true);

        // mark non-primes <= N using Sieve of Eratosthenes
        for (int i = 2; i*i <= 100000000; i++)
        {

             if (isPrime[i])
             {
                for (int j = i; i*j <= 100000000; j++) {
                    isPrime[i*j] = false;
                }
            }
        }
}

*/

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

       // package ba7s;

import java.util.Scanner;

/**
 *
 * @author marten
 */
public class Ba7s {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner f=new Scanner (System.in);
        String s=f.next();
        int x=s.length();
        int m ,w=0;
        char[]c=new char[x+1];
        for(int i=0;i<x;i++){
          c[i]=s.charAt(i);
        }
        if(x%2==0){
           m=x/2;
        }else{
          m=(x+1)/2;
        }
          if(x==1)
               c[1]=c[0];
              for(int i=0;i<(m-1);i++){
               for(int j=(m-1);j<x;j++){
                   if(s.charAt(i)==s.charAt(j)){
                         w++;
                 // System.out.print(s.charAt(i));
                         break;
                   }
               }
           }
              System.out.print(w + ""+m);
                if(w<(m-1)){
             System.out.print("NA");
          }else{
        for(int i=0,k=(x-1);i<(m-1);i++,k--){
                 if(c[i]!=c[k]&&c[i]!=c[k-1]){
                    for(int j=0,n=x;j<m;j++,n--){
                        c[n]=c[j];
                         // System.out.print("first half");
                    }
                 }
        }
        for(int i=0,k=(x-1);i<(m-1);i++,k--){
             if(c[k]!=c[i]&&c[k]!=c[i+1]){
                 for(int e=x;e>0;e--){
                  c[e]=c[e-1];
                 }
                 for(int j=0,n=x;j<m;j++,n--){
                     c[j]=c[n];
                   // System.out.print("second half");
                  }
             }
        }
              if(c[m-1]==c[m]){
             c[m]='w';
             for(int j=0,n=x;j<m;j++,n--){
                   c[n]=c[j];
              //System.out.print("i will add letter");
             }
         }else{
            for(int j=0,n=x;j<m;j++,n--){
               c[n]=c[j];
                // System.out.print("half");
            }
          }
       for(int i=0;i<(x+1);i++){
         System.out.print(c[i]);
       }
    }
  }
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Aaa {

	public static void main(String[] args) {
            Scanner input=new Scanner (System.in);
            String s=input.next();
            StringBuilder a=new StringBuilder(s);
             boolean c=false ;
     /*      if (isPalindrome(s)){
            if (s.length()%2==0){s=a.insert(s.length()/2, "a").toString();}
            else {s=a.insert(s.length()/2, "a").toString();}
            c=true;
            }

           */

            for (int i=0;i<=s.length()&&c==false;i++){
            for (int j=97;j<122;j++){
            String x=new String(s);
            StringBuilder z=new StringBuilder(x);
            x=z.insert(i, (char)j).toString();
            if (isPalindrome(x)){s=x;c=true; break ;}

            }

            }
           if (c==false){s="NA";}

            System.out.print(s);

	}

public static boolean isPalindrome(String s ) {
int low = 0;

 int high = s.length()- 1;

 while (low < high) {
 if( s.charAt(low) != s.charAt(high))
return false;

 low++;
 high--;
 }

return true;
 }

}