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;
struct marix {
  int r, c;
  int a[410][410];
  inline void init(int x) {
    r = c = x;
    for (int i = 1; i <= x; i++) a[i][i] = 1;
  }
} x, y;
inline void muti(marix &ans, const marix x, const marix y) {
  ans.r = ans.c = x.r;
  for (int i = 1; i <= x.r; i++)
    for (int j = i; j <= y.c; j++) {
      int tmp = 0;
      for (int k = i; k <= j; k++) (tmp += x.a[i][k] * y.a[k][j]) %= 10007;
      ans.a[i][j] = tmp;
    }
}
inline void power(marix &ans, marix x, int y) {
  ans.init(x.r);
  for (; y; y >>= 1) {
    if (y & 1) muti(ans, ans, x);
    muti(x, x, x);
  }
}
int f[210][210][210];
char s[410];
inline int calc(int l, int r, int x) {
  int &u = f[x][l][r];
  if (u != -1) return u;
  u = 0;
  if (l == r) return u = x == 0;
  if (s[l] == s[r]) {
    if (l + 1 == r) return u = x == 0;
    return u = calc(l + 1, r - 1, x);
  }
  if (x > 0) return u = (calc(l + 1, r, x - 1) + calc(l, r - 1, x - 1)) % 10007;
  return u;
}
int main() {
  int n, m;
  memset(f, -1, sizeof(f));
  scanf("%s", s + 1);
  scanf("%d", &n);
  m = strlen(s + 1);
  n += m;
  int l = (n + 1) / 2, n24 = m - 1, n25 = (m + 1) / 2, n26 = n25;
  x.r = x.c = n24 + n25 + n26;
  for (int i = 1; i <= n24; i++) x.a[i][i] = 24, x.a[i][i + 1] = 1;
  for (int i = n24 + 1; i <= n25 + n24; i++)
    x.a[i][i] = 25, x.a[i][i + n25] = 1;
  for (int i = n24 + n25 + 1; i <= n25 + n24 + n26; i++) x.a[i][i] = 26;
  for (int i = n24 + 1; i < n25 + n24; i++) x.a[i][i + 1] = 1;
  marix y;
  power(y, x, l - 1);
  muti(x, y, x);
  int ans;
  for (int i = 0; i <= n24; i++) {
    int j = (m - i + 1) / 2, k = l - i - j;
    if (k < 0) continue;
    int sum = calc(1, m, i);
    (ans += sum * x.a[n24 - i + 1][n24 + j + n25] % 10007) %= 10007;
    if ((n & 1) && (m - i & 1 ^ 1))
      (ans = ans - sum * y.a[n24 - i + 1][n24 + j] % 10007 + 10007) %= 10007;
  }
  printf("%d\n", ans);
  return 0;
}