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".
import java.util.Arrays;
import java.util.Scanner;

public class E {
	static int mod = 1_000_7;
	
	static int N;
	static char[] str;
	static int[][][] dp;
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		str = in.next().toCharArray();
		N = str.length;
		int goal = N + in.nextInt();
		
		int len = 1500;
		dp = new int[N+1][N+1][len+1];
		for(int a[][]:dp)
			for(int b[]:a)
				Arrays.fill(b, -1);
				
		long[] seq = new long[len];
		for(int i = 0; i < len; i++) seq[i] = go(0,0,i);
		long res = work(seq, goal);
		System.out.println(res%mod);
	}
	
	static int go(int matchL, int matchR, int left) {
		if(dp[matchL][matchR][left] != -1) return dp[matchL][matchR][left];
		if(left == 0) return matchL + matchR >= N ? 1 : 0;
		int res = 0;
		
		boolean canL = matchL < N, canR = matchR < N;
		boolean leqr = matchL < N && matchR < N && str[matchL] == str[N-1-matchR];
		
		int matchNone = 26;
		if(canL) matchNone--;
		if(canR) matchNone--;
		if(leqr) matchNone++;
		
		res += matchNone * go(matchL, matchR, max(0, left-2));
		
		if(leqr && left > 1) {
			// match both
			res += go(matchL+1, matchR+1, max(0, left-2));
		}
		else {
			// match left only
			if(canL && ((!leqr) || left == 1)) {
				res += go(matchL+1, matchR, max(0, left-2));
			}
			
			// match right
			if(canR && !leqr) {
				res += go(matchL, matchR+1, max(0, left-2));
			}
		}
		res %= mod;
		
//		for(char place = 'a'; place <= 'z'; place++) {
//			int newL = matchL < N && str[matchL] == place ? matchL+1 : matchL;
//			int newR = matchR < N && left > 1 && str[N-1-matchR] == place ? matchR+1: matchR;
//			int newLeft = Math.max(0, left-2);
//			res += go(newL, newR, newLeft);
//			if(res >= mod) res -= mod;
//		}
		return dp[matchL][matchR][left] = res;
	}
	
	static int max(int a, int b) { return a > b ? a : b;}
	

	static long pow(long a, long p) {
		if(p == 0) return 1;
		if((p&1) == 0) {
			long x = pow(a, p>>1);
			return (x*x)%mod;
		}
		else return (a*pow(a,p-1))%mod;
	}
	
	
	static long[] BM(long[] x) {
		long[] ls = {}, cur = {};
		int lf = 0;
		long ld = 0;
		for(int i = 0; i < x.length; i++) {
			long t = 0;
			for(int j = 0; j < cur.length; j++)
				t = (t+x[i-j-1]*cur[j])%mod;
			if(t == x[i]) continue;
			if(cur.length == 0) {
				cur = new long[i+1];
				lf = i; ld = (t-x[i])%mod;
				continue;
			}
			long k = (-(x[i]-t)*pow(ld, mod-2))%mod;
			long c[] = new long[Math.max(cur.length, i-lf+ls.length)];
			int idd = i-lf-1;
			c[idd++] = k;
			for(int j = 0; j < ls.length; j++) c[idd++] = -ls[j]*k%mod;
			for(int j = 0; j < cur.length; j++) c[j] = (c[j]+cur[j])%mod;
			if(i-lf+ls.length >= cur.length) {
				ls = cur;
				lf = i;
				ld = (t-x[i])%mod;
			}
			cur = c;
		}
		for(int i = 0; i < cur.length; i++) cur[i] = (cur[i]%mod+mod)%mod;
		return cur;
	}
	
	static int m, SZ = 2_000_00;
	static long[] a = new long[SZ];
	static long[] h = new long[SZ];
	static long[] t_ = new long[SZ];
	static long[] s = new long[SZ];
	static long[] t = new long[SZ];

	static void mull(long[] p, long[] q) {
		for(int i = 0; i < m+m; i++) t_[i] = 0;
		for(int i = 0; i < m; i++) if(p[i] != 0)
			for(int j = 0; j < m; j++)
				t_[i+j] = (t_[i+j]+p[i]*q[j])%mod;
		for(int i = m+m-1; i >= m; i--) if(t_[i] != 0)
			for(int j = m-1; (~j) != 0; j--)
				t_[i-j-1] = (t_[i-j-1]+t_[i]*h[j])%mod;
		for(int i = 0; i < m; i++) p[i] = t_[i];
	}
	
	static long calc(long K) {
		for(int i = m; (~i) != 0; i--) {
			s[i] = t[i] = 0;
		}
		s[0] = 1; if(m != 1) t[1] = 1; else t[0] = h[0];
		while(K != 0) {
			if((K&1) != 0) mull(s,t);
			mull(t,t); K>>=1;
		}
		long su = 0;
		for(int i = 0; i < m; i++) su = (su+s[i]*a[i])%mod;
		return (su%mod+mod)%mod;
	}
	
	static long work(long[] x, long n) {
		if(n < x.length) return x[(int)n];
		long[] v = BM(x);
		m = v.length;
		if(m == 0) return 0;
		for(int i = 0; i < m; i++) {
			h[i] = v[i]; 
			a[i] = x[i];
		}
		return calc(n);
	}

}
