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 f[210][210][210], g[210], n, m, S, ans = 0;
const int p = 10007;
struct mat {
  long long v[210 * 2][210 * 2];
  mat(int tp = 0) {
    memset(v, 0, sizeof(v));
    if (tp) {
      for (int i = 1; i <= S; i++) v[i][i] = 1;
    }
  }
  mat operator*(const mat &rhs) const {
    mat ret;
    for (int i = 1; i <= S; i++) {
      for (int k = i; k <= S; k++) {
        long long tmp = v[i][k];
        for (int j = k; j <= S; j++) ret.v[i][j] += tmp * rhs.v[k][j];
      }
    }
    for (int i = 1; i <= S; i++) {
      for (int j = i; j <= S; j++) ret.v[i][j] %= p;
    }
    return ret;
  }
} bs;
char s[210];
mat pw(mat a, int b) {
  mat ret = mat(1);
  while (b) {
    if (b & 1) ret = ret * a;
    a = a * a, b >>= 1;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> s + 1 >> n, n += m = strlen(s + 1), S = 2 * m + (m & (-m));
  for (int i = 1; i <= m; i++) bs.v[i][i] = 24, bs.v[i][i + 1] = 1;
  for (int i = m + 1; i <= m + (m + 1) / 2; i++) {
    bs.v[i][i] = 25, bs.v[i][i + (m + 1) / 2] = 1;
    bs.v[i + (m + 1) / 2][i + (m + 1) / 2] = 26;
    if (i < m + (m + 1) / 2) bs.v[i][i + 1] = 1;
  }
  f[1][m][0] = 1;
  for (int i = 1; i <= m; i++) {
    for (int j = m; j >= i; j--) {
      for (int l = 0; l <= m; l++) {
        if (s[i] == s[j])
          f[i + 1][j - 1][l] = (f[i + 1][j - 1][l] + f[i][j][l]) % p;
        if (l < m && s[i] != s[j]) {
          f[i][j - 1][l + 1] = (f[i][j - 1][l + 1] + f[i][j][l]) % p;
          f[i + 1][j][l + 1] = (f[i + 1][j][l + 1] + f[i][j][l]) % p;
        }
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j <= m; j++) {
      g[j] = (g[j] + f[i][i][j]) % p;
      if (i < m && s[i] == s[i + 1]) g[j] = (g[j] + f[i][i + 1][j]) % p;
    }
  }
  mat res = pw(bs, n / 2);
  if (~n & 1) {
    for (int i = 0; i <= m; i++) {
      int tmp = (m - i + 1) / 2;
      ans =
          (ans + 1LL * g[i] * res.v[m - i + 1][m + (m + 1) / 2 + tmp] % p) % p;
    }
  } else {
    for (int i = 2; i <= m + 1; i++) {
      for (int j = 0; j <= m; j++) {
        if ((m - j) & 1) continue;
        int tmp = (m - j + 1) / 2;
        ans = (ans - 1LL * f[i][i - 1][j] * res.v[m - j + 1][m + tmp] % p + p) %
              p;
      }
    }
    res = res * bs;
    for (int i = 0; i <= m; i++) {
      int tmp = (m - i + 1) / 2;
      ans =
          (ans + 1LL * g[i] * res.v[m - i + 1][m + (m + 1) / 2 + tmp] % p) % p;
    }
  }
  cout << ans << endl;
  return 0;
}