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 N = 205, M = 10007;
typedef class Matrix {
 public:
  int a[N << 1][N << 1];
  Matrix() {}
  Matrix(int n) {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) a[i][j] = ((i == j) ? (1) : (0));
  }
  int* operator[](int p) { return a[p]; }
  void debug() {
    for (int i = 0; i < 11; i++, cerr << endl)
      for (int j = 0; j < 11; j++) cerr << a[i][j] << " ";
  }
} Matrix;
char str[N];
int n, m, es, l;
int f[N][N][N];
inline void init() {
  scanf("%s%d", str + 1, &m);
  n = strlen(str + 1);
}
void modplus(int& a, int b) {
  a += b;
  if (a < 0) a += M;
  if (a >= M) a -= M;
}
inline void dp() {
  f[1][n][0] = 1;
  for (int l = n - 1; ~l; l--) {
    for (int i = 1, j; (j = i + l) <= n; i++) {
      for (int k = 0; k <= n; k++) {
        if (!f[i][j][k]) continue;
        if (str[i] == str[j]) {
          if (i + 1 == j || i == j)
            modplus(f[0][0][k], f[i][j][k]);
          else
            modplus(f[i + 1][j - 1][k], f[i][j][k]);
        } else {
          modplus(f[i + 1][j][k + 1], f[i][j][k]);
          modplus(f[i][j - 1][k + 1], f[i][j][k]);
        }
      }
    }
  }
}
Matrix operator*(Matrix a, Matrix b) {
  Matrix rt;
  for (int i = 0; i < es; i++)
    for (int j = i; j < es; j++) {
      rt[i][j] = 0;
      for (int k = i; k <= j; k++)
        rt[i][j] = (rt[i][j] + a[i][k] * b[k][j]) % M;
    }
  return rt;
}
Matrix qpow(Matrix& a, int pos) {
  Matrix pa = a, rt = Matrix(es);
  for (; pos; pos >>= 1, pa = pa * pa)
    if (pos & 1) rt = rt * pa;
  return rt;
}
Matrix g, tem, bas;
inline void solve() {
  int N24 = n - 1, N25 = (n + 1) >> 1, N26 = N25;
  es = N24 + N25 + N26, l = (m + n + 1) >> 1;
  for (int i = 0; i < N24; i++) g[i][i + 1] = 1, g[i][i] = 24;
  for (int i = N24; i < N24 + N25; i++) {
    g[i][i + N25] = 1, g[i][i] = 25;
    if (i < N24 + N25 - 1) g[i][i + 1] = 1;
  }
  for (int i = N24 + N25; i < es; i++) g[i][i] = 26;
  bas = g;
  tem = g = qpow(bas, l - 1);
  g = g * bas;
  int res = 0;
  bool aflag;
  for (int i = 0, n25, c; i <= N24; i++) {
    n25 = (n - i + 1) >> 1, aflag = !((n - i) & 1);
    c = f[0][0][i];
    res = (res + c * g[N24 - i][N24 + N25 + n25 - 1]) % M;
    if (((n + m) & 1) && aflag)
      res = (res - (c * tem[N24 - i][N24 + n25 - 1]) % M + M) % M;
  }
  printf("%d\n", res);
}
int main() {
  init();
  dp();
  solve();
  return 0;
}