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;
const int N = 205, mod = 1e4 + 7;
char s[N];
int n, m, f[N][N][N][2], g[32][N << 1][N << 1], val[N << 1], pre[N << 1], cnt;
int calc_(int T) {
  memset(val, 0, sizeof(val)), T++;
  for (int p = 1; p < 31; p++) {
    memset(g[p], 0, sizeof(g[p]));
    for (int i = 0; i <= cnt; i++)
      for (int k = i; k <= cnt; k++)
        for (int j = k; j <= cnt; j++)
          g[p][i][j] =
              (g[p][i][j] + 1ll * g[p - 1][i][k] * g[p - 1][k][j]) % mod;
  }
  val[0] = 1;
  for (int k = 30; k >= 0; k--)
    if (T & (1 << k)) {
      for (int i = 0; i <= cnt; i++) pre[i] = val[i], val[i] = 0;
      for (int i = 0; i <= cnt; i++)
        for (int j = i; j <= cnt; j++)
          val[j] = (val[j] + 1ll * pre[i] * g[k][i][j]) % mod;
    }
  return val[cnt];
}
int main() {
  scanf("%s%d", s + 1, &m), n = strlen(s + 1);
  for (int i = 1; i <= n; i++)
    for (int l = 1, r; (r = l + i - 1) <= n; l++) {
      if (l == r) {
        f[l][r][0][0] = 1;
        continue;
      }
      if (r - l == 1 && s[l] == s[r]) {
        f[l][r][0][1] = 1;
        continue;
      }
      for (int j = 0; j <= r - l + 1; j++)
        for (int k = 0; k < 2; k++)
          if (s[l] == s[r])
            f[l][r][j][k] = f[l + 1][r - 1][j][k];
          else if (j)
            f[l][r][j][k] =
                (f[l][r - 1][j - 1][k] + f[l + 1][r][j - 1][k]) % mod;
    }
  cnt = n << 1 | 1;
  for (int i = 0; i < cnt; i++)
    if (i != n) g[0][i][i + 1] = 1;
  for (int i = 0; i <= n; i++)
    g[0][i][cnt - (n + 1 - i) / 2] =
        (1ll * g[0][i][cnt - (n + 1 - i) / 2] + f[1][n][i][0] + f[1][n][i][1]) %
        mod;
  for (int i = 1; i < cnt; i++) g[0][i][i] = 24 + (i > n);
  g[0][cnt][cnt] = 26;
  int ans = calc_((n + m + 1) >> 1);
  if ((n + m) & 1) {
    g[0][cnt][cnt] = 0;
    for (int i = 0; i <= n; i++) g[0][i][cnt - (n + 1 - i) / 2] = 0;
    for (int i = 0; i <= n; i++)
      g[0][i][cnt - (n + 1 - i) / 2] =
          (g[0][i][cnt - (n + 1 - i) / 2] + f[1][n][i][1]) % mod;
    ans = (ans - calc_((n + m + 1) >> 1)) % mod;
  }
  printf("%d\n", (ans % mod + mod) % mod);
}