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 inf = ~0u >> 1, mo = 10007;
inline int rd() {
  int x, c, f = 1;
  while (!isdigit(c = getchar())) f = c != '-';
  x = c - '0';
  while (isdigit(c = getchar())) x = x * 10 + c - '0';
  return f ? x : -x;
}
const int N = 205;
int n, m, cnt, tot, dp[N][N][N], g[N << 1][N << 1];
char s[N];
struct matrix {
  int p[N << 1][N << 1];
} a, b;
void operator*=(matrix &x, const matrix y) {
  memset(g, 0, sizeof(g));
  for (int i = (1), i_end = (tot); i <= i_end; ++i)
    for (int j = (i), j_end = (tot); j <= j_end; ++j)
      for (int k = (j), k_end = (tot); k <= k_end; ++k)
        g[i][k] = (g[i][k] + x.p[i][j] * y.p[j][k]) % mo;
  swap(x.p, g);
}
void ksm(matrix x, int y) {
  for (int i = (1), i_end = (tot); i <= i_end; ++i)
    for (int j = (1), j_end = (tot); j <= j_end; ++j) b.p[i][j] = (i == j);
  for (; y; y >>= 1, x *= x)
    if (y & 1) b *= x;
}
int main() {
  scanf("%s%d", s + 1, &m);
  n = strlen(s + 1), m += n;
  for (int i = (1), i_end = (n); i <= i_end; ++i) {
    dp[i][i][0] = 1;
    if (i < n && s[i] == s[i + 1]) dp[i][i + 1][0] = 1;
  }
  for (int i = (n - 1), i_st = (1); i >= i_st; --i)
    for (int j = ((s[i] == s[i + 1]) ? i + 2 : i + 1), j_end = (n); j <= j_end;
         ++j)
      if (s[i] == s[j])
        for (int k = (0), k_end = (n); k <= k_end; ++k)
          dp[i][j][k] = dp[i + 1][j - 1][k];
      else
        for (int k = (1), k_end = (n); k <= k_end; ++k)
          dp[i][j][k] = (dp[i][j - 1][k - 1] + dp[i + 1][j][k - 1]) % mo;
  int ans = 0;
  cnt = n + 1 >> 1;
  for (int i = (1), i_end = (n); i < i_end; ++i)
    a.p[i][i] = 24, a.p[i][i + 1] = 1;
  for (int i = (n), i_end = (n + cnt); i < i_end; ++i)
    a.p[i][i] = 25, a.p[i][i + cnt] = a.p[i - 1][i] = 1;
  tot = n + (cnt << 1) - 1;
  for (int i = (n + cnt), i_end = (tot); i <= i_end; ++i) a.p[i][i] = 26;
  ksm(a, m - 1 >> 1), a *= b;
  for (int i = (0), i_end = (n); i < i_end; ++i) {
    int j = n - i - 1 >> 1, k = a.p[n - i][n + cnt + j];
    if ((m & 1) && !(n - i & 1)) k = (k - b.p[n - i][n + j] + mo) % mo;
    ans = (ans + dp[1][n][i] * k) % mo;
  }
  cout << ans << endl;
}