Problem: Mr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly n lowercase English letters 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 n lowercase English letters, and insert each of them to any position of s, possibly to the beginning or the end of s. You have to insert exactly n letters even if it is possible to turn s into a palindrome by inserting less than n letters.

Find the number of the palindromes that can be obtained in this way, modulo 10007.

Input

The first line contains a string s (1 ≤ |s| ≤ 200). Each character in s is a lowercase English letter.

The second line contains an integer n (1 ≤ n ≤ 109).

Output

Print the number of the palindromes that can be obtained, modulo 10007.

Examples

Input

revive
1


Output

1


Input

add
2


Output

28

Note

For the first sample, you can obtain the palindrome "reviver" by inserting 'r' to the end of "revive".

For the second sample, the following 28 palindromes can be obtained: "adada", "adbda", ..., "adzda", "dadad" and "ddadd".

Solution (in JAVA):

Solution:
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; 
}