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 N(305), Mod(10007), LIM(Mod *Mod);
int n, m, cnt, col[N][N], h[N][N][N], g[N];
char s[N];
struct Matrix {
  int a[N][N];
  inline int *operator[](const int &x) { return a[x]; }
  inline const int *operator[](const int &x) const { return a[x]; }
} F, G;
inline void Add(int &x, int y) {
  x += y;
  if (x >= LIM) x %= Mod;
}
Matrix operator*(const Matrix &a, const Matrix &b) {
  Matrix c;
  std::memset(c.a, 0, sizeof c.a);
  for (int i = 0; i <= cnt; i++)
    for (int k = i; k <= cnt; k++)
      for (int j = k; j <= cnt; j++) Add(c[i][j], a[i][k] * b[k][j]);
  for (int i = 0; i <= cnt; i++)
    for (int j = i; j <= cnt; j++) c[i][j] %= Mod;
  return c;
}
void Pow(int y) {
  for (; y; y >>= 1, G = G * G)
    if (y & 1) F = F * G;
}
int main() {
  scanf("%s%d", s + 1, &m), n = strlen(s + 1), h[1][n][0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = n; j >= i; j--)
      if (s[i] == s[j]) {
        for (int k = 0; k < i + n - j; k++)
          if (i + 1 < j)
            h[i + 1][j - 1][k] = (h[i + 1][j - 1][k] + h[i][j][k]) % Mod;
          else
            g[k] = (g[k] + h[i][j][k]) % Mod;
      } else {
        for (int k = 0; k < i + n - j; k++)
          h[i][j - 1][k + 1] = (h[i][j - 1][k + 1] + h[i][j][k]) % Mod,
                          h[i + 1][j][k + 1] =
                              (h[i + 1][j][k + 1] + h[i][j][k]) % Mod;
      }
  cnt = n + 1 + (n + 1) / 2, F[0][1] = 1, F[0][n + 1] = g[0], G[cnt][cnt] = 26;
  for (int i = 1, j; i <= n; i++)
    j = cnt - (n - i + 1) / 2, G[i][i] = 24, G[i][j] = g[i];
  for (int i = 1; i < n; i++) G[i][i + 1] = 1;
  for (int i = n + 1; i < cnt; i++) G[i][i] = 25, G[i][i + 1] = 1;
  Pow((n + m + 1) >> 1);
  if ((n + m) & 1) {
    int ans = F[0][cnt];
    std::memset(g, 0, sizeof g);
    std::memset(F.a, 0, sizeof F.a), std::memset(G.a, 0, sizeof G.a);
    for (int i = 1; i < n; i++)
      if (s[i] == s[i + 1])
        for (int k = 0; k <= n; k++) g[k] = (g[k] + h[i][i + 1][k]) % Mod;
    F[0][1] = 1, F[0][n + 1] = g[0];
    for (int i = 1, j; i <= n; i++)
      j = cnt - (n - i + 1) / 2, G[i][i] = 24, G[i][j] = g[i];
    for (int i = 1; i < n; i++) G[i][i + 1] = 1;
    for (int i = n + 1; i < cnt; i++) G[i][i] = 25, G[i][i + 1] = 1;
    Pow((n + m + 1) >> 1);
    printf("%d\n", (ans - F[0][cnt] + Mod) % Mod);
  } else
    printf("%d\n", F[0][cnt]);
  return 0;
}