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>
char s[208LL];
int f[208LL][208LL][208LL] = {0};
inline void dp(int n, int del = 0) {
  int l, r, k;
  if (del) memset(f, 0, sizeof f);
  for (l = (n); l >= (1); l--)
    for (r = (l); r <= (n); r++) {
      if (del) {
        if (l == r) continue;
        if (r == l + 1) {
          f[l][r][0] = (s[l] == s[r] ? 1 : 0);
          continue;
        }
      } else if (l == r) {
        f[l][r][0] = 1;
        continue;
      }
      if (s[l] == s[r]) {
        if (l + 1 <= r - 1)
          for (k = (0); k <= (n); k++) f[l][r][k] = f[l + 1][r - 1][k];
        if (r == l + 1) f[l][r][0] = 1;
      } else {
        f[l][r][0] = 0;
        for (k = (1); k <= (n); k++)
          f[l][r][k] = (f[l + 1][r][k - 1] + f[l][r - 1][k - 1]) % 10007LL;
      }
    }
}
inline int pow(int x, int p) {
  if (p <= 0) return 1;
  int ret = 1;
  for (; p; p >>= 1, (x *= x) %= 10007LL)
    if (p & 1) (ret *= x) %= 10007LL;
  return ret;
}
struct Mat {
  int n, a[208LL * 3 / 2][208LL * 3 / 2];
  Mat() {}
  Mat(int n) {
    this->n = n;
    memset(a, 0, sizeof a);
  }
  inline void init(int n) {
    this->n = n;
    memset(a, 0, sizeof a);
  }
  inline void one() {
    int i;
    for (i = (1); i <= (n); i++) a[i][i] = 1;
  }
  inline Mat operator*(const Mat &B) const {
    Mat ret(n);
    int i, j, k;
    for (i = (1); i <= (n); i++)
      for (j = (i); j <= (n); j++)
        for (k = (i); k <= (j); k++)
          (ret.a[i][j] += a[i][k] * B.a[k][j] % 10007LL) %= 10007LL;
    return ret;
  }
  inline Mat operator^(const int &B) const {
    int p = B;
    Mat x = *this, ret(n);
    for (ret.one(); p; p >>= 1, x = x * x)
      if (p & 1) ret = ret * x;
    return ret;
  }
  inline void print() {
    int i, j;
    puts("/----------\\");
    for (i = (1); i <= (n); i++) {
      for (j = (1); j <= (n); j++) printf("%2d ", a[i][j]);
      puts("");
    }
    puts("\\----------/");
  }
} T, A;
int g[208LL][208LL];
inline int solve(int *f, int n, int len, int del = 0) {
  if (del) memset(g, 0, sizeof g);
  int i, j, h = (n + 1) / 2, GOAL = n + h + 1;
  for (i = (0); i <= (n); i++) g[i][(n - i + 1) / 2] = f[i];
  for (i = (0); i < (n); i++)
    for (j = (1); j <= (h); j++) {
      (g[i + 1][j] += g[i][j]) %= 10007LL;
      (g[i + 1][j - 1] += g[i][j]) %= 10007LL;
      g[i][j] = 0;
    }
  T.init(n + h + 1), A.init(n + h + 1), A.a[1][1] = 1;
  for (i = (1); i < (n + h); i++) T.a[i][i + 1] = 1;
  for (i = (1); i <= (n + h); i++) T.a[i][i] = (i <= n ? 24 : 25);
  for (i = (h); i <= (n + h); i++)
    T.a[i][GOAL] = (i <= n ? g[i][0] : g[n][i - n]);
  T.a[GOAL][GOAL] = (del ? 25 : 26);
  T = T ^ len, A = A * T;
  return A.a[1][GOAL];
}
int main() {
  int n, m, ans, len;
  scanf("%s%d", s + 1, &m), n = strlen(s + 1);
  dp(n);
  len = (n + m + 1) / 2;
  ans = solve(f[1][n], n, len);
  if ((n + m) % 2 == 0 || n == 1) {
  } else if (n == 2) {
    if (s[1] == s[2]) ans = (ans - pow(25, len - 1) + 10007LL) % 10007LL;
  } else {
    dp(n, 1);
    ans = (ans - solve(f[1][n], n - 2, len - 1, 1) + 10007LL) % 10007LL;
  }
  printf("%d\n", ans);
  return 0;
}