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.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;
                             int check=0;
                             String h="";
                             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+1)==n.charAt(j)&&n.charAt(i)==n.charAt(j-1)){
                                     String q=n;
                                     String n1=n.substring(0,j+1)+n.charAt(i)+n.substring(j+1,le);
                                     String n2=n.substring(0,i)+n.charAt(j)+n.substring(i,le);
                                     if(s(n1).equals(n1)||s(n2).equals(n2)){
                                         count++;
                                         check++;
                                         if(s(n1).equals(n1))
                                             h=n1;
                                         else
                                             h=n2;
                                         break;
                                         
                                     }
                                     else{
                                         count=-1;
                                         break;
                                     }
                                 }
                                 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 if(check!=0)
                                 System.out.println(h);
                             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;
                     }
        }