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 mod = 1e4 + 7;
struct Matrix {
  int w, h;
  int mat[305][305];
  Matrix(int W = 0, int H = 0) {
    for (int i = 1; i <= W; ++i)
      for (int j = 1; j <= H; ++j) mat[i][j] = 0;
    w = W;
    h = H;
    return;
  }
  Matrix operator*(Matrix y) {
    Matrix res(w, y.h);
    for (int i = 1; i <= w; ++i)
      for (int j = i; j <= y.h; ++j)
        for (int k = i; k <= j; ++k)
          (res.mat[i][j] += mat[i][k] * y.mat[k][j]) %= mod;
    return res;
  }
  Matrix operator^(int y) {
    Matrix x = *this, res(w, h);
    for (int i = 1; i <= w; ++i) res.mat[i][i] = 1;
    for (; y; y >>= 1, x = x * x)
      if (y & 1) res = res * x;
    return res;
  }
};
char s[305];
int n, m, lim;
int h[305][305][305], f[305];
int H(int, int, int);
int main() {
  scanf("%s%d", s + 1, &n);
  m = strlen(s + 1);
  n += m;
  lim = m + (m + 1) / 2 + 1;
  memset(h, -1, sizeof h);
  for (int i = 0; i <= m; ++i) h[i][1][m] = 0;
  h[s[1] != s[m]][1][m] = 1;
  for (int i = 1; i <= m; ++i)
    for (int j = 0; j <= m; ++j) {
      (f[j] += H(j, i, i)) %= mod;
      if (s[i] == s[i + 1]) (f[j] += H(j, i, i + 1)) %= mod;
    }
  Matrix A(lim, lim);
  for (int i = 2; i <= m; ++i) A.mat[i][i] = 24, A.mat[i - 1][i] = 1;
  for (int i = m + 1; i <= m + (m + 1) / 2; ++i) {
    if (i != m + 1) A.mat[i - 1][i] = 1;
    A.mat[i][i] = 25;
    int tmp = ((m + 1) / 2 - (i - m) + 1) * 2;
    int pos1 = m - tmp, pos2 = m - tmp + 1;
    A.mat[pos1 + 1][i] = f[pos1];
    A.mat[pos2 + 1][i] = f[pos2];
  }
  A.mat[lim - 1][lim] = 1;
  A.mat[lim][lim] = 26;
  A = A ^ ((n + 1) / 2 + 1);
  int res = A.mat[1][lim];
  if (n & 1) {
    A = Matrix(lim, lim);
    memset(f, 0, sizeof f);
    for (int i = 1; i <= m; ++i)
      for (int j = 0; j <= m; ++j)
        if (s[i] == s[i + 1]) (f[j] += H(j, i, i + 1)) %= mod;
    for (int i = 2; i <= m; ++i) A.mat[i][i] = 24, A.mat[i - 1][i] = 1;
    for (int i = m + 1; i <= m + (m + 1) / 2; ++i) {
      if (i != m + 1) A.mat[i - 1][i] = 1;
      A.mat[i][i] = 25;
      int tmp = ((m + 1) / 2 - (i - m) + 1) * 2;
      int pos1 = m - tmp, pos2 = m - tmp + 1;
      A.mat[pos1 + 1][i] = f[pos1];
      A.mat[pos2 + 1][i] = f[pos2];
    }
    A.mat[lim - 1][lim] = 1;
    A = A ^ ((n + 1) / 2 + 1);
    res = (res - A.mat[1][lim] + mod) % mod;
  }
  cout << res << endl;
  return 0;
}
int H(int num, int l, int r) {
  if (!l || r > m || num < 0) return 0;
  if (h[num][l][r] != -1) return h[num][l][r];
  h[num][l][r] = 0;
  int pre = num - (s[l] != s[r]);
  if (s[l - 1] != s[r]) h[num][l][r] += H(pre, l - 1, r);
  if (s[l] != s[r + 1]) h[num][l][r] += H(pre, l, r + 1);
  if (s[l - 1] == s[r + 1]) h[num][l][r] += H(pre, l - 1, r + 1);
  h[num][l][r] %= mod;
  return h[num][l][r];
}