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;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
char ch[205];
int n, m, f[205][205][205], g[205], MAXN;
struct Martix {
  int a[205 << 1][205 << 1];
} A, B;
Martix operator*(Martix a, Martix b) {
  Martix c;
  memset(c.a, 0, sizeof(c));
  for (int i = 0; i <= MAXN; i++) {
    for (int j = i; j <= MAXN; j++) {
      for (int k = i; k <= j; k++) {
        c.a[i][j] += a.a[i][k] * b.a[k][j];
        c.a[i][j] %= 10007;
      }
    }
  }
  return c;
}
void ksm(int b) {
  while (b) {
    if (b & 1) A = A * B;
    B = B * B;
    b >>= 1;
  }
}
int main() {
  scanf("%s", ch);
  m = read();
  n = strlen(ch);
  f[0][n - 1][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = n - 1; j >= i; j--) {
      if (ch[i] == ch[j]) {
        for (int k = 0; k < i + n - j; k++) {
          if (i + 1 < j)
            f[i + 1][j - 1][k] += f[i][j][k], f[i + 1][j - 1][k] %= 10007;
          else
            g[k] += f[i][j][k], g[k] %= 10007;
        }
      } else {
        for (int k = 0; k < i + n - j; k++) {
          f[i + 1][j][k + 1] += f[i][j][k], f[i + 1][j][k + 1] %= 10007;
          f[i][j - 1][k + 1] += f[i][j][k], f[i][j - 1][k + 1] %= 10007;
        }
      }
    }
  }
  MAXN = n + (n + 1) / 2 + 1;
  A.a[0][1] = 1;
  A.a[0][n + 1] = g[0];
  B.a[MAXN][MAXN] = 26;
  for (int i = 1; i <= n; i++)
    B.a[i][i] = 24, B.a[i][i + 1] = 1, B.a[i][MAXN - (n - i + 1) / 2] = g[i];
  B.a[n][n + 1] = 0;
  for (int i = n + 1; i < MAXN; i++) B.a[i][i + 1] = 1, B.a[i][i] = 25;
  if ((n + m) % 2 == 1) {
    ksm((n + m + 1) / 2);
    int ans = A.a[0][MAXN];
    memset(A.a, 0, sizeof(A.a));
    memset(B.a, 0, sizeof(B.a));
    memset(g, 0, sizeof(g));
    for (int i = 0; i < n - 1; i++) {
      if (ch[i] == ch[i + 1]) {
        for (int j = 0; j <= n; j++) {
          g[j] += f[i][i + 1][j];
          g[j] %= 10007;
        }
      }
    }
    A.a[0][1] = 1;
    A.a[0][n + 1] = g[0];
    for (int i = 1; i <= n; i++)
      B.a[i][i] = 24, B.a[i][i + 1] = 1, B.a[i][MAXN - (n - i + 1) / 2] = g[i];
    B.a[n][n + 1] = 0;
    for (int i = n + 1; i < MAXN; i++) B.a[i][i + 1] = 1, B.a[i][i] = 25;
    ksm((n + m + 1) / 2);
    printf("%d\n", (ans - A.a[0][MAXN] + 10007) % 10007);
  } else {
    ksm((n + m) / 2);
    printf("%d\n", A.a[0][MAXN]);
  }
  return 0;
}