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 P = 10007;
inline int mul(const int &a, const int &b) { return a * b % P; }
inline int add(int a, const int &b) {
  a += b;
  return (a >= P) ? a - P : a;
}
inline int sub(int a, const int &b) {
  a -= b;
  return (a < 0) ? a + P : a;
}
int f[210][210][210], n, nl, mx0, mx1, mat[410][410], ans[410][410],
    tem[410][410], fin;
char s[210];
long long T = 0;
int main() {
  scanf("%s%d", s + 1, &n);
  n += (nl = strlen(s + 1));
  f[0][nl + 1][0] = 1;
  for (int i = 0; i <= nl; i++)
    for (int j = nl + 1; j > i; --j)
      for (int k = 0; k <= nl; k++)
        if (s[i + 1] == s[j - 1] && i + 1 != j - 1)
          f[i + 1][j - 1][k] = add(f[i + 1][j - 1][k], f[i][j][k]);
        else if (i + 1 == j - 1)
          f[i + 1][j][k] = add(f[i + 1][j][k], f[i][j][k]);
        else
          f[i + 1][j][k + 1] = add(f[i + 1][j][k + 1], f[i][j][k]),
                          f[i][j - 1][k + 1] =
                              add(f[i][j - 1][k + 1], f[i][j][k]);
  int cnt = (nl << 1) + 1;
  for (int i = 1; i < nl; i++) mat[i][i + 1] = 1;
  for (int i = 1; i <= nl; i++) mat[i][i] = 25;
  for (int i = nl + 1; i < cnt; i++) mat[i][i + 1] = 1;
  for (int i = nl + 1; i < cnt; i++) mat[i][i] = 24;
  mat[cnt][cnt] = 26;
  for (int i = 0; i <= nl; i++)
    for (int k = 0; k <= nl; k++)
      mat[((nl - k + 1) >> 1)][cnt - k] =
          add(mat[((nl - k + 1) >> 1)][cnt - k], f[i][i + 1][k]);
  for (int i = 1; i <= cnt; i++) ans[i][i] = 1;
  int orig = n;
  n = n >> 1;
  while (n) {
    if (n & 1) {
      memset(tem, 0, sizeof tem);
      for (int i = 1; i <= cnt; i++)
        for (int j = i; j <= cnt; j++) {
          T = 0;
          for (int k = i; k <= j; k++) T += ans[i][k] * mat[k][j];
          tem[i][j] = T % P;
        }
      memcpy(ans, tem, sizeof tem);
    }
    memset(tem, 0, sizeof tem);
    for (int i = 1; i <= cnt; i++)
      for (int j = i; j <= cnt; j++) {
        T = 0;
        for (int k = i; k <= j; k++) T += mat[i][k] * mat[k][j];
        tem[i][j] = T % P;
      }
    memcpy(mat, tem, sizeof tem);
    n >>= 1;
  }
  fin = ans[1][cnt];
  if (orig % 2 == 1) {
    int cnt = (nl << 1) + 1;
    memset(mat, 0, sizeof mat);
    for (int i = 1; i < nl; i++) mat[i][i + 1] = 1;
    for (int i = 1; i <= nl; i++) mat[i][i] = 25;
    for (int i = nl + 1; i < cnt; i++) mat[i][i + 1] = 1;
    for (int i = nl + 1; i < cnt; i++) mat[i][i] = 24;
    for (int i = 0; i <= nl; i++)
      for (int k = 0; k < nl; k++)
        mat[((nl - k) >> 1) + 1][cnt - k] =
            add(mat[((nl - k) >> 1) + 1][cnt - k], f[i][i + 2][k]);
    for (int i = 1; i <= cnt; i++)
      for (int j = 1; j <= cnt; j++) ans[i][j] = (i == j);
    n = (orig + 1) >> 1;
    while (n) {
      if (n & 1) {
        memset(tem, 0, sizeof tem);
        for (int i = 1; i <= cnt; i++)
          for (int j = i; j <= cnt; j++) {
            T = 0;
            for (int k = i; k <= j; k++) T += ans[i][k] * mat[k][j];
            tem[i][j] = T % P;
          }
        memcpy(ans, tem, sizeof tem);
      }
      memset(tem, 0, sizeof tem);
      for (int i = 1; i <= cnt; i++)
        for (int j = i; j <= cnt; j++) {
          T = 0;
          for (int k = i; k <= j; k++) T += mat[i][k] * mat[k][j];
          tem[i][j] = T % P;
        }
      memcpy(mat, tem, sizeof tem);
      n >>= 1;
    }
    printf("%d\n", add(mul(fin, 26), ans[1][cnt]));
  } else
    printf("%d\n", fin);
}