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>
struct mat {
  int z[200 * 2 + 5][200 * 2 + 5];
} x, y;
inline mat operator*(const mat& a, const mat& b) {
  mat c;
  register int i, j, k;
  long long r[200 * 2 + 5][200 * 2 + 5];
  memset(r, 0, sizeof(r));
  for (i = 1; i <= 200 * 2; ++i)
    for (j = 1; j <= 200 * 2; ++j)
      for (k = 1; k <= 200 * 2; ++k) r[i][k] += a.z[i][j] * b.z[j][k];
  for (i = 1; i <= 200 * 2; ++i)
    for (j = 1; j <= 200 * 2; ++j) c.z[i][j] = r[i][j] % 10007;
  return c;
}
char s[200 + 5];
int f[200 + 5][200 + 5][200 + 5], ans;
inline void rw(int& a, int b) {
  if ((a += b) >= 10007) a -= 10007;
}
int main() {
  int n, m, i, j, k;
  scanf("%s%d", s + 1, &m);
  n = strlen(s + 1);
  for (i = 1; i <= 200; ++i) x.z[i][i] = 24, x.z[i][i + 1] = 1;
  for (i = 1; i <= 200 / 2; ++i)
    x.z[200 + i][200 + i] = 25, i < 200 / 2 ? x.z[200 + i][200 + i + 1] = 1 : 0,
                       x.z[200 + i][200 + 200 / 2 + i] = 1,
                       x.z[200 + 200 / 2 + i][200 + 200 / 2 + i] = 26;
  for (i = 1; i <= 200 + 200; ++i) y.z[i][i] = 1;
  for (k = n + m >> 1; k; k >>= 1, x = x * x)
    if (k & 1) y = y * x;
  f[1][n][0] = 1;
  for (i = 1; i <= n; ++i)
    for (j = n; j >= i; --j)
      for (k = 0; k <= n; ++k)
        if (f[i][j][k])
          if (s[i] == s[j])
            rw(f[i + 1][j - 1][k + 1], f[i][j][k]);
          else
            rw(f[i + 1][j][k], f[i][j][k]), rw(f[i][j - 1][k], f[i][j][k]);
  if ((n + m) & 1) {
    for (i = 1; i <= n; ++i)
      for (k = 0; k <= n; ++k)
        if (f[i + 1][i - 1][k])
          ans =
              (ans + f[i + 1][i - 1][k] *
                         y.z[200 - n + 2 * k][200 + 200 / 2 + k] % 10007 * 26) %
              10007;
    for (i = 1; i < n; ++i)
      for (k = 0; k <= n; ++k)
        if (f[i + 1][i][k])
          ans = (ans + f[i + 1][i][k] *
                           y.z[200 + 1 - n + 2 * k][200 + 200 / 2 + k] % 10007 *
                           26) %
                10007;
    for (i = 1; i <= n; ++i)
      for (k = 0; k <= n; ++k)
        if (f[i][i][k])
          ans = (ans + f[i][i][k] * y.z[200 + 2 - n + 2 * k][200 + k + 1]) %
                10007;
  } else {
    for (i = 1; i <= n; ++i)
      for (k = 0; k <= n; ++k)
        if (f[i + 1][i - 1][k])
          ans = (ans +
                 f[i + 1][i - 1][k] * y.z[200 - n + 2 * k][200 + 200 / 2 + k]) %
                10007;
    for (i = 1; i < n; ++i)
      for (k = 0; k <= n; ++k)
        if (f[i + 1][i][k])
          ans = (ans +
                 f[i + 1][i][k] * y.z[200 + 1 - n + 2 * k][200 + 200 / 2 + k]) %
                10007;
  }
  printf("%d", ans);
}