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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int re = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (isdigit(ch)) re = (re << 1) + (re << 3) + ch - '0', ch = getchar();
  return re * flag;
}
int n, m, len, n1, n2, n3;
char s[1010];
inline void add(int &a, int b) {
  a += b;
  if (a >= 10007) a -= 10007;
}
inline void dec(int &a, int b) {
  a -= b;
  if (a < 0) a += 10007;
}
struct mat {
  int a[410][410];
  mat() { memset(a, 0, sizeof(a)); }
  inline void init() {
    for (int i = 1; i <= len; i++) a[i][i] = 1;
  }
  inline friend void out(mat x) {
    for (int i = 1; i <= len; i++) {
      for (int j = 1; j <= len; j++) cout << x.a[i][j] << ' ';
      cout << '\n';
    }
  }
  inline friend mat operator*(const mat &x, const mat &b) {
    mat re;
    int i, j, k;
    for (i = 1; i <= len; i++) {
      for (j = i; j <= len; j++) {
        for (k = i; k <= j; k++) add(re.a[i][j], x.a[i][k] * b.a[k][j] % 10007);
      }
    }
    return re;
  }
  inline friend mat qpow(mat x, int t) {
    mat re;
    re.init();
    while (t) {
      if (t & 1) re = re * x;
      x = x * x;
      t >>= 1;
    }
    return re;
  }
} a, b;
int dp[210][210][210];
inline int calc(int x, int l, int r) {
  if (~dp[x][l][r]) return dp[x][l][r];
  dp[x][l][r] = 0;
  if (l == r) return dp[x][l][r] = (x == 0);
  if (s[l] == s[r])
    return (l + 1 == r ? (dp[x][l][r] = (x == 0))
                       : (dp[x][l][r] = calc(x, l + 1, r - 1)));
  if (x > 0)
    return dp[x][l][r] =
               (calc(x - 1, l + 1, r) + calc(x - 1, l, r - 1)) % 10007;
  return dp[x][l][r];
}
int main() {
  memset(dp, -1, sizeof(dp));
  int i, j, k, tim, tmp, ans = 0;
  scanf("%s", s + 1);
  n = strlen(s + 1);
  m = read() + n;
  tim = ((1 + m) >> 1);
  n1 = n - 1;
  n2 = (n + 1) >> 1;
  n3 = n2;
  len = n1 + n2 + n3;
  for (i = 1; i <= n1; i++) a.a[i][i] = 24, a.a[i][i + 1] = 1;
  for (i = n1 + 1; i <= n1 + n2; i++)
    a.a[i][i] = 25, a.a[i][i + n2] = 1, a.a[i - 1][i] = 1;
  for (i = n1 + n2 + 1; i <= len; i++) a.a[i][i] = 26;
  b = qpow(a, tim - 1);
  a = b * a;
  for (i = 0; i <= n1; i++) {
    j = (n + 1 - i) >> 1;
    k = tim - i - j;
    if (k < 0) continue;
    tmp = calc(i, 1, n) % 10007;
    add(ans, tmp * a.a[n1 - i + 1][n1 + n2 + j] % 10007);
    if ((m & 1) && (((n - i) & 1) ^ 1))
      dec(ans, tmp * b.a[n1 - i + 1][n1 + j] % 10007);
  }
  cout << ans << '\n';
}