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;
const int P = 1e4 + 7;
int upd(int x) { return x + (x >> 31 & P); }
void inc(int &a, int b) { a = upd(a + b - P); }
char str[203];
int dp[203][203][203], L, N, coef[403], val[203][203][2];
void mul(int *pol, int v2) {
  for (int i = 2 * L + 1; i; --i) pol[i] = (pol[i] + pol[i - 1] * v2) % P;
}
int f[803], tmp[803], ans[803], arr[803];
void mul(int *A, int *B) {
  memset(tmp, 0, sizeof(tmp));
  for (int i = 0; i <= 2 * L; ++i)
    if (B[i])
      for (int j = 0; j <= 2 * L; ++j)
        tmp[i + j] = (tmp[i + j] + B[i] * A[j]) % P;
  for (int i = 4 * L; i > 2 * L; --i)
    if (tmp[i]) {
      for (int p = 0; p <= 2 * L; ++p)
        tmp[i - 2 * L - 1 + p] =
            (tmp[i - 2 * L - 1 + p] - f[p] * tmp[i] % P + P) % P;
      tmp[i] = 0;
    }
  memcpy(A, tmp, sizeof(tmp));
}
void calc() {
  f[0] = ans[0] = arr[1] = 1;
  mul(f, P - 26);
  for (int i = 1; i <= L; ++i) {
    mul(f, P - 24);
    mul(f, P - 25);
  }
  for (int i = 0; i <= 2 * L; ++i) f[i] = f[i + 1];
  reverse(f, f + 2 * L + 1);
  f[2 * L + 1] = 1;
  int step = (N + L) / 2;
  while (step) {
    if (step & 1) mul(ans, arr);
    mul(arr, arr);
    step >>= 1;
  }
  memset(arr, 0, sizeof(arr));
  arr[1] = 1;
  for (int i = 0; i <= 2 * L; ++i) {
    coef[i] = ans[2 * L];
    mul(ans, arr);
  }
}
int main() {
  scanf("%s %d", str + 1, &N);
  L = strlen(str + 1);
  dp[1][L][0] = 1;
  for (int i = 1; i <= L; ++i)
    for (int j = L; j >= i; --j)
      for (int k = 0; k <= L; ++k)
        if (dp[i][j][k])
          if (str[i] == str[j])
            inc(dp[i + 1][j - 1][k], dp[i][j][k]);
          else {
            inc(dp[i + 1][j][k + 1], dp[i][j][k]);
            inc(dp[i][j - 1][k + 1], dp[i][j][k]);
          }
  for (int i = 1; i <= L + 1; ++i)
    for (int k = 0; k <= L; ++k) {
      if (dp[i][i][k]) {
        int p = 1 + (L - 1 - k) / 2;
        if ((N + L) & 1) inc(val[k][p][0], dp[i][i][k]);
        inc(val[k][p][1], dp[i][i][k] * ((N + L) & 1 ? 26 : 1) % P);
      }
      if (dp[i][i - 1][k])
        inc(val[k][(L - k) / 2][1],
            dp[i][i - 1][k] * ((N + L) & 1 ? 26 : 1) % P);
    }
  calc();
  int ans = 0;
  for (int i = 0; i <= L; ++i)
    for (int j = 0; j <= L; ++j)
      for (int k = 0; k <= 1; ++k)
        if (val[i][j][k]) {
          static int pol[403];
          memset(pol, 0, sizeof(pol));
          pol[i + j + k - 1] = 1;
          for (int p = i + 1; p <= L; ++p) mul(pol, P - 24);
          for (int p = j + 1; p <= L; ++p) mul(pol, P - 25);
          for (int p = k + 1; p <= 1; ++p) mul(pol, P - 26);
          int sum = 0;
          for (int p = 0; p <= 2 * L; ++p)
            inc(sum, pol[p] * coef[2 * L - p] % P);
          inc(ans, sum * val[i][j][k] % P);
        }
  printf("%d\n", ans);
  return 0;
}