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 maxn = 405, mod = 1e4 + 7;
char s[maxn];
int n, m, n24, n25, n26, len, f[maxn][maxn][maxn];
struct matrix {
  int n, m, a[maxn][maxn];
  matrix(int _n = 0, int _m = 0) {
    n = _n;
    m = _m;
    memset(a, 0, sizeof(a));
  }
  int* operator[](int x) { return a[x]; }
  matrix operator*(matrix b) {
    matrix ans(n, b.m);
    for (int i = 0; i <= n; ++i)
      for (int j = 0; j <= n; ++j)
        for (int k = i; k <= j; ++k)
          ans[i][j] = (ans[i][j] + a[i][k] * b[k][j]) % mod;
    return ans;
  }
} A, B;
matrix fpow(matrix A, int k) {
  matrix res = matrix(A.n, A.m);
  for (int i = 0; i <= res.n; ++i) res[i][i] = 1;
  while (k) {
    if (k & 1) res = res * A;
    k >>= 1;
    A = A * A;
  }
  return res;
}
int main() {
  scanf("%s%d", s + 1, &m);
  n = strlen(s + 1);
  for (int i = 0; i <= n; ++i)
    for (int l = n; l >= 1; --l)
      for (int r = l; r <= n; ++r)
        if (l == r)
          f[i][l][r] = i == 0;
        else if (s[l] == s[r])
          f[i][l][r] = l + 1 == r ? i == 0 : f[i][l + 1][r - 1];
        else if (i) {
          f[i][l][r] = f[i - 1][l + 1][r] + f[i - 1][l][r - 1];
          if (f[i][l][r] >= mod) f[i][l][r] -= mod;
        }
  n24 = n - 1;
  n25 = (n + 1) >> 1;
  n26 = n25;
  len = n24 + n25 + n26;
  A.n = A.m = len;
  for (int i = 1; i <= n24; ++i) A[i][i] = 24, A[i][i + 1] = 1;
  for (int i = n24 + 1; i <= n24 + n25; ++i)
    A[i][i] = 25, A[i][i + n25] = A[i - 1][i] = 1;
  for (int i = n24 + n25 + 1; i <= len; ++i) A[i][i] = 26;
  m += n;
  B = fpow(A, (m + 1) / 2 - 1);
  A = A * B;
  int ans = 0;
  for (int i = 0, j; i <= n24; ++i) {
    if ((m + 1) / 2 < i + (j = (n + 1 - i) / 2)) continue;
    ans = (ans + f[i][1][n] * A[n24 - i + 1][n24 + n25 + j]) % mod;
    if ((m & 1) && (~(n - i) & 1))
      ans = (ans + (mod - f[i][1][n]) * B[n24 - i + 1][n24 + j]) % mod;
  }
  printf("%d\n", ans);
  return 0;
}