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 n, m, L, ans, dp[310][310][310], sum[310];
char str[310];
inline void Add(int &u, int v) { u += v, u %= 10007; }
struct Jz {
  int num[310][310];
  Jz() { memset(num, 0, sizeof(num)); }
  void clear() { memset(num, 0, sizeof(num)); }
  Jz operator*(const Jz &u) const {
    int i, j, k;
    Jz res;
    for (i = 0; i <= L; i++) {
      for (j = i; j <= L; j++) {
        for (k = i; k <= L; k++) {
          Add(res.num[i][j], num[i][k] * u.num[k][j] % 10007);
        }
      }
    }
    return res;
  }
} dw, st, an;
inline Jz po(Jz u, int v) {
  int i;
  Jz res;
  for (i = 0; i <= L; i++) res.num[i][i] = 1;
  for (; v;) {
    if (v & 1) res = res * u;
    u = u * u;
    v >>= 1;
  }
  return res;
}
int main() {
  int i, j, k, t;
  scanf("%s%d", str + 1, &m);
  n = strlen(str + 1);
  dp[1][n][0] = 1;
  for (i = 1; i <= n; i++) {
    for (j = n; j >= i; j--) {
      if (str[i] == str[j]) {
        for (k = 0; k <= n; k++) {
          if (!dp[i][j][k]) continue;
          if (j - i > 1)
            Add(dp[i + 1][j - 1][k], dp[i][j][k]);
          else
            Add(sum[k], dp[i][j][k]);
        }
      } else {
        for (k = 0; k <= n; k++) {
          if (!dp[i][j][k]) continue;
          Add(dp[i + 1][j][k + 1], dp[i][j][k]);
          Add(dp[i][j - 1][k + 1], dp[i][j][k]);
        }
      }
    }
  }
  st.num[0][1] = 1;
  st.num[0][n] = sum[0];
  t = (n + 1) / 2;
  L = n + t;
  for (i = 1; i < n; i++) {
    dw.num[i][L - (n - i + 1) / 2] = sum[i];
    dw.num[i][i] = 24;
    if (i < n - 1) dw.num[i][i + 1] = 1;
  }
  for (i = n; i < L; i++) {
    dw.num[i][i] = 25;
    dw.num[i][i + 1] = 1;
  }
  dw.num[L][L] = 26;
  an = st * po(dw, (n + m + 1) >> 1);
  ans = an.num[0][L];
  if ((n + m) & 1) {
    dw.clear();
    memset(sum, 0, sizeof(sum));
    for (i = 1; i < n; i++) {
      if (str[i] != str[i + 1]) continue;
      for (j = 0; j <= n; j++) {
        Add(sum[j], dp[i][i + 1][j]);
      }
    }
    st.num[0][n] = sum[0];
    for (i = 1; i < n; i++) {
      dw.num[i][L - (n - i + 1) / 2] = sum[i];
      dw.num[i][i] = 24;
      if (i < n - 1) dw.num[i][i + 1] = 1;
    }
    for (i = n; i < L; i++) {
      dw.num[i][i] = 25;
      dw.num[i][i + 1] = 1;
    }
    an = st * po(dw, (n + m + 1) >> 1);
    Add(ans, 10007 - an.num[0][L]);
  }
  cout << ans;
}