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>
const int N = 205, M = 305, mod = 10007;
int l, n, f[N][N][N], cnt[N];
char s[N];
struct Matrix {
  int v[M][M], len;
  inline void init(int l) {
    len = l, memset(v, 0, sizeof(v));
    for (int i = 0; i < l; ++i) v[i][i] = 1;
    return;
  }
  inline Matrix& operator*=(Matrix& x) {
    static int res[M][M];
    memset(res, 0, sizeof(res));
    for (int i = 0; i < len; ++i)
      for (int k = i; k < len; ++k)
        for (int j = k; j < len; ++j)
          res[i][j] = (res[i][j] + v[i][k] * x.v[k][j]) % mod;
    memcpy(v, res, sizeof(v));
    return *this;
  }
} trans, res, bas;
int ans;
inline int qpow(int pw) {
  bas.init(trans.len);
  memset(bas.v, 0, sizeof(bas.v));
  bas.v[0][0] = 1;
  res.init(trans.len);
  for (; pw; pw >>= 1, trans *= trans)
    if (pw & 1) res *= trans;
  return res.v[0][res.len - 1];
}
int main(void) {
  scanf("%s%d", s + 1, &n), l = strlen(s + 1);
  for (int i = 1; i <= l; ++i) f[i][i][0] = 1;
  for (int i = 1; i < l; ++i)
    if (s[i] == s[i + 1]) f[i][i + 1][0] = 1;
  for (int k = 1; k <= l; ++k)
    for (int i = 1; i + k - 1 <= l; ++i) {
      int j = i + k - 1;
      for (int x = (s[i] != s[j]); x <= l; ++x)
        f[i][j][x] =
            (f[i][j][x] + (s[i] == s[j]
                               ? f[i + 1][j - 1][x]
                               : (f[i + 1][j][x - 1] + f[i][j - 1][x - 1]))) %
            mod;
    }
  for (int i = 0; i <= l; ++i) cnt[i] = f[1][l][i];
  int pw = (n + l + 1) >> 1;
  trans.len = l + 1 + (l + 1) / 2 + 1;
  for (int i = 0; i < l; ++i) trans.v[i][i + 1] = 1;
  for (int i = l + 1; i < trans.len - 1; ++i) trans.v[i][i + 1] = 1;
  for (int i = 1; i < l + 1; ++i) trans.v[i][i] = 24;
  for (int i = l + 1; i < trans.len - 1; ++i) trans.v[i][i] = 25;
  trans.v[trans.len - 1][trans.len - 1] = 26;
  for (int i = 0; i <= l; ++i)
    trans.v[i][trans.len - 1 - (l - i + 1) / 2] = cnt[i];
  ans = qpow(pw + 1);
  if ((l + n) & 1) {
    memset(f, 0, sizeof(f));
    memset(cnt, 0, sizeof(cnt));
    for (int i = 1; i < l; ++i)
      if (s[i] == s[i + 1]) f[i][i + 1][0] = 1;
    for (int k = 1; k <= l; ++k)
      for (int i = 1; i + k - 1 <= l; ++i) {
        int j = i + k - 1;
        for (int x = (s[i] != s[j]); x <= l; ++x)
          f[i][j][x] =
              (f[i][j][x] + (s[i] == s[j]
                                 ? f[i + 1][j - 1][x]
                                 : (f[i + 1][j][x - 1] + f[i][j - 1][x - 1]))) %
              mod;
      }
    for (int i = 0; i <= l; ++i) cnt[i] = f[1][l][i];
    memset(trans.v, 0, sizeof(trans.v));
    for (int i = 0; i < l; ++i) trans.v[i][i + 1] = 1;
    for (int i = l + 1; i < trans.len - 1; ++i) trans.v[i][i + 1] = 1;
    for (int i = 1; i < l + 1; ++i) trans.v[i][i] = 24;
    for (int i = l + 1; i < trans.len - 1; ++i) trans.v[i][i] = 25;
    for (int i = 0; i <= l; ++i)
      trans.v[i][trans.len - 1 - (l - i + 1) / 2] = cnt[i];
    int res = qpow(pw + 1);
    ans = ((ans - res) % mod + mod) % mod;
  }
  printf("%d\n", ans);
  return 0;
}