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 i, j, k, n, m, nn, an;
int a[210 * 2][210 * 2], b[210 * 2][210 * 2], f[210][210][210];
char p[210];
inline void mul(int a[210 * 2][210 * 2], int b[210 * 2][210 * 2]) {
  int i, j, k, c[210 * 2][210 * 2] = {};
  for (i = 1; i <= nn; i++)
    for (j = i; j <= nn; j++)
      for (k = j; k <= nn; k++) c[i][k] = (a[i][j] * b[j][k] + c[i][k]) % 10007;
  for (i = 1; i <= nn; i++)
    for (j = i; j <= nn; j++) a[i][j] = c[i][j];
}
inline void S(int &x, int y) { x = (x + y) % 10007; }
inline void pre() {
  int i, j, k, u, x;
  f[1][m][0] = 1;
  for (i = m - 1; i >= 0; i--)
    for (j = 1; j <= m - i; j++)
      for (k = 0; k <= m; k++) {
        u = j + i;
        if ((x = f[j][u][k]) > 0) {
          if (p[j] == p[u])
            S(f[j + 1][u - 1][k], x);
          else
            S(f[j + 1][u][k + 1], x), S(f[j][u - 1][k + 1], x);
        }
      }
}
int main() {
  scanf("%s%d", p + 1, &n);
  m = strlen(p + 1);
  pre();
  n += m;
  int flag = n & 1;
  n /= 2;
  int n24 = m, n25 = (m + 1) / 2, n26 = n25 + 1;
  nn = n24 + n25 + n26;
  for (i = 1; i <= n24 + n25 - 1; i++) a[i][i + 1] = 1;
  for (i = 0; i <= n25; i++) a[n24 + i][nn - i] = 1;
  for (i = 1; i <= n24; i++) a[i][i] = 24;
  for (i = 1; i <= n25; i++) a[n24 + i][n24 + i] = 25;
  for (i = 1; i <= n26; i++) a[n24 + n25 + i][n24 + n25 + i] = 26;
  for (i = 1; i <= nn; i++) b[i][i] = 1;
  for (k = n; k; k /= 2) {
    if (k & 1) mul(b, a);
    mul(a, a);
  }
  for (i = 0; i <= m; i++) {
    int v24 = i, v25 = (m - i + 1) / 2, s = 0;
    for (j = 1; j <= m; j++) S(s, f[j + 1][j - 1][i]), S(s, f[j][j - 1][i]);
    an =
        (s * b[n24 - v24 + 1][nn - v25] % 10007 * (flag ? 26 : 1) + an) % 10007;
    if (flag && (m - v24) % 2 == 1) {
      s = 0;
      for (j = 1; j <= m; j++) S(s, f[j][j][i]);
      an = (s * b[n24 - v24 + 1][n24 + v25] + an) % 10007;
    }
  }
  printf("%d\n", an);
  return 0;
}