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>
const int MN = 400 + 5, P = 10007;
using namespace std;
template <typename T>
inline T& IN(T& in) {
  in = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) in = in * 10 + c - '0', c = getchar();
  return in *= f;
}
int n, m, N, ans;
char c[MN];
int f[210][210][210];
struct mat {
  int a[MN][MN];
  mat() { memset(a, 0, sizeof a); }
} sum, res, tmp;
void mul(mat& ans, const mat x, const mat y) {
  for (int i = 1; i <= N; i++)
    for (int j = i; j <= N; j++) {
      int tmp = 0;
      for (int k = i; k <= j; k++) tmp = (tmp + x.a[i][k] * y.a[k][j]) % P;
      ans.a[i][j] = tmp;
    }
}
void qp(int b) {
  while (b) {
    if (b & 1) mul(res, res, sum);
    mul(sum, sum, sum);
    b >>= 1;
  }
}
int calc(int l, int r, int x) {
  int& u = f[x][l][r];
  if (u != -1) return u;
  u = 0;
  if (l == r) return u = x == 0;
  if (c[l] == c[r]) {
    if (l + 1 == r) return u = x == 0;
    return u = calc(l + 1, r - 1, x);
  }
  if (x > 0) return u = (calc(l + 1, r, x - 1) + calc(l, r - 1, x - 1)) % P;
  return u;
}
void input() {
  memset(f, -1, sizeof f);
  scanf("%s", c + 1);
  IN(n);
  m = strlen(c + 1);
  n += m;
  int a = m - 1, b = (m + 1) / 2, c = b, l = n + 1 >> 1;
  N = a + b + c;
  for (int i = 1; i <= a; ++i) sum.a[i][i] = 24, sum.a[i][i + 1] = 1;
  for (int i = a + 1; i <= a + b; ++i) sum.a[i][i] = 25, sum.a[i][i + b] = 1;
  for (int i = a + 1; i < a + b; ++i) sum.a[i][i + 1] = 1;
  for (int i = a + b + 1; i <= a + b + c; ++i) sum.a[i][i] = 26;
  for (int i = 1; i <= a + b + c; ++i) res.a[i][i] = 1;
  tmp = sum, qp(l - 1);
  mul(tmp, res, tmp);
  for (int i = 0, l = n + 1 >> 1; i <= a; ++i) {
    int j = (m - i + 1) / 2, k = l - i - j;
    if (k < 0) continue;
    int sum = calc(1, m, i);
    ans = (ans + sum * tmp.a[a - i + 1][a + j + b] % P) % P;
    if ((n & 1) && (m - i & 1 ^ 1))
      ans = (ans - sum * res.a[a - i + 1][a + j] % P + P) % P;
  }
  printf("%d\n", ans);
}
int main() {
  input();
  return 0;
}