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.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());
    }
    
    

}