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 read() {
  char a = getchar();
  int res = 0, f = 1;
  while (a < '0' || a > '9') {
    if (a == '-') f = -1;
    a = getchar();
  }
  while (a >= '0' && a <= '9') res = res * 10 + a - '0', a = getchar();
  return res * f;
}
const int p = 10007;
int n, len;
char s[205];
int f1[205];
void upd(int& x, int y) { x = (x + y) % p; }
int dp[205][205][205];
bool vis[205][205][205];
int DP(int l, int r, int k) {
  if (vis[l][r][k]) return dp[l][r][k];
  vis[l][r][k] = 1;
  int& res = dp[l][r][k];
  if (res) return res;
  if (l == r) {
    if (!k) res = 1;
  } else {
    if (s[l] == s[r]) {
      if (l + 1 == r) {
        if (!k) res = 1;
      } else
        res = DP(l + 1, r - 1, k);
    } else {
      if (k) res = (DP(l + 1, r, k - 1) + DP(l, r - 1, k - 1)) % p;
    }
  }
  return res;
}
void pre() {
  for (int k = 0; k <= len; k++) f1[k] = DP(1, len, k);
}
int tot;
struct Ma {
  int g[405][405];
  Ma() { memset(g, 0, sizeof(g)); }
  Ma operator*(const Ma& b) const {
    static long long f[405][405];
    for (int i = 1; i <= tot; i++)
      for (int j = 1; j <= tot; j++) f[i][j] = 0;
    Ma res;
    for (int i = 1; i <= tot; i++)
      for (int k = i; k <= tot; k++)
        if (g[i][k])
          for (int j = k; j <= tot; j++) f[i][j] += g[i][k] * b.g[k][j];
    for (int i = 1; i <= tot; i++)
      for (int j = 1; j <= tot; j++) res.g[i][j] = f[i][j] % p;
    return res;
  }
  void w() {
    for (int i = 1; i <= tot; i++) g[i][i] = 1;
  }
} sta, sta1, sta2;
Ma pf(const Ma& x, int c) {
  Ma res, t = x;
  res.w();
  while (c) {
    if (c & 1) res = res * t;
    t = t * t;
    c >>= 1;
  }
  return res;
}
signed main() {
  scanf("%s", s + 1);
  len = strlen(s + 1);
  n = read() + len;
  pre();
  int cnt24 = len - 1;
  int cnt25 = (len + 1) >> 1;
  int cnt26 = cnt25;
  tot = cnt24 + cnt25 + cnt26;
  for (int i = 1; i <= cnt24; i++) sta.g[i][i] = 24, sta.g[i][i + 1] = 1;
  for (int i = cnt24 + 1; i <= cnt24 + cnt25; i++)
    sta.g[i][i] = 25, sta.g[i][i + 1] = 1, sta.g[i][i + cnt25] = 1;
  if (cnt25 != 1) sta.g[cnt24 + cnt25][cnt24 + cnt25 + 1] = 0;
  for (int i = cnt24 + cnt25 + 1; i <= tot; i++) sta.g[i][i] = 26;
  sta1 = pf(sta, (n + 1) / 2 - 1);
  sta2 = sta1 * sta;
  int ans = 0;
  for (int n26, n25, n24 = 0; n24 <= cnt24; n24++) {
    n25 = (len - n24 + 1) >> 1;
    n26 = (n + 1) / 2 - n24 - n25;
    if (n26 < 0) continue;
    int f = f1[n24];
    ans = (ans + f * sta2.g[cnt24 - n24 + 1][cnt25 + cnt24 + n25]) % p;
    if (n % 2 == 1 && (len - n24) % 2 == 0)
      ans = (ans - f * sta1.g[cnt24 - n24 + 1][cnt24 + n25] % p + p) % p;
  }
  printf("%d\n", ans);
  return 0;
}