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>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,no-stack-protector")
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "\n";
  err(++it, args...);
}
function<void(void)> ____ = []() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
};
template <typename T>
vector<T> &operator<<(vector<T> &__container, T x) {
  __container.push_back(x);
  return __container;
}
template <typename T>
ostream &operator<<(ostream &out, vector<T> &__container) {
  for (T _ : __container) out << _ << ' ';
  return out;
}
void sci() {}
template <typename... Args>
void sci(int &x, Args &...args) {
  scanf("%d", &x);
  sci(args...);
}
void scl() {}
template <typename... Args>
void scl(long long int &x, Args &...args) {
  scanf("%lld", &x);
  scl(args...);
}
const int MAXN = 207;
const int MAXM = 307;
const int MOD = 1e4 + 7;
struct Matrix {
  int mat[MAXM][MAXM];
  Matrix(int x = 0) {
    for (int i = 0; i < MAXM; i++)
      for (int j = 0; j < MAXM; j++) mat[i][j] = i == j ? x : 0;
  }
  int *operator[](const int idx) { return mat[idx]; }
  Matrix operator*(Matrix rhs) {
    Matrix ret(0);
    for (int i = 0; i < MAXM; i++)
      for (int j = i; j < MAXM; j++)
        for (int k = i; k <= j; k++)
          ret[i][j] = (ret[i][j] + mat[i][k] * rhs[k][j]) % MOD;
    return ret;
  }
  Matrix operator^(int b) {
    Matrix ret(1), A(*this);
    while (b) {
      if (b & 1) ret = ret * A;
      b >>= 1;
      A = A * A;
    }
    return ret;
  }
} M, S;
char s[MAXN];
int n, m, f[MAXN][MAXN][MAXN], g[MAXN];
void solve() {
  scanf("%s", s + 1);
  sci(m);
  n = strlen(s + 1);
  f[1][n][0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = n; j >= i; j--)
      for (int k = 0; k <= n - j + i - 1; k++) {
        if (s[i] == s[j]) {
          if (i + 1 >= j)
            g[k] = (g[k] + f[i][j][k]) % MOD;
          else
            f[i + 1][j - 1][k] = (f[i + 1][j - 1][k] + f[i][j][k]) % MOD;
        } else {
          f[i + 1][j][k + 1] = (f[i + 1][j][k + 1] + f[i][j][k]) % MOD;
          f[i][j - 1][k + 1] = (f[i][j - 1][k + 1] + f[i][j][k]) % MOD;
        }
      }
  int N = n + (n + 1) / 2 + 1;
  S[0][1] = 1;
  S[0][N - (n + 1) / 2] = g[0];
  M[N][N] = 26;
  for (int i = 1; i <= n; i++) {
    M[i][N - (n - i + 1) / 2] = g[i];
    M[i][i] = 24;
    if (i != n) M[i][i + 1] = 1;
  }
  for (int i = n + 1; i < N; i++) M[i][i + 1] = 1, M[i][i] = 25;
  if ((n + m) & 1) {
    S = S * (M ^ ((n + m + 1) >> 1));
    int ret = S[0][N];
    memset(S.mat, 0, sizeof(S.mat));
    memset(M.mat, 0, sizeof(M.mat));
    memset(g, 0, sizeof(g));
    for (int i = 1; i < n; i++)
      if (s[i] == s[i + 1])
        for (int k = 0; k <= n; k++) g[k] = (g[k] + f[i][i + 1][k]) % MOD;
    S[0][1] = 1;
    S[0][N - (n + 1) / 2] = g[0];
    for (int i = 1; i <= n; i++) {
      M[i][N - (n - i + 1) / 2] = g[i];
      M[i][i] = 24;
      if (i != n) M[i][i + 1] = 1;
    }
    for (int i = n + 1; i < N; i++) M[i][i + 1] = 1, M[i][i] = 25;
    S = S * (M ^ ((n + m + 1) >> 1));
    ret = (ret - S[0][N] + MOD) % MOD;
    cout << ret << "\n";
  } else {
    S = S * (M ^ ((n + m + 1) >> 1));
    cout << S[0][N] << "\n";
  }
}
int main() {
  solve();
  return 0;
}