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 max_N = 207;
const int mod = 10007;
int n, m, dp[max_N][max_N][max_N];
char s[max_N];
int read() {
  char c = getchar();
  int ans = 0;
  bool flag = true;
  while (!isdigit(c)) flag &= (c != '-'), c = getchar();
  while (isdigit(c)) ans = 10 * ans + c - '0', c = getchar();
  return flag ? ans : -ans;
}
void Write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x < 10)
    putchar(x + '0');
  else
    Write(x / 10), putchar(x % 10 + '0');
}
int min(int x, int y) { return x < y ? x : y; }
int max(int x, int y) { return x > y ? x : y; }
void _min(int &x, int y) {
  if (x > y) x = y;
}
void _max(int &x, int y) {
  if (x < y) x = y;
}
int plus(int x, int y) { return (x += y) >= mod ? x - mod : x; }
int minus(int x, int y) { return (x -= y) < 0 ? x + mod : x; }
int fma(int x, int y, int z) { return (x + y * z) % mod; }
void _plus(int &x, int y) {
  if ((x += y) >= mod) x -= mod;
}
void _minus(int &x, int y) {
  if ((x -= y) < 0) x += mod;
}
void _fma(int &x, int y, int z) { x = (x + y * z) % mod; }
int _inv(int x) { return x == 1 ? 1 : (mod - mod / x) * _inv(mod % x) % mod; }
namespace matrix_base {
int size;
std::vector<std::vector<int> > O, I;
}  // namespace matrix_base
void init_matrix(int n) {
  using namespace matrix_base;
  size = n;
  O.clear(), I.clear();
  O.resize(n), I.resize(n);
  for (int i = 0; i < n; i++) O[i].resize(n), I[i].resize(n), I[i][i] = 1;
}
std::vector<std::vector<int> > operator*(std::vector<std::vector<int> > A,
                                         std::vector<std::vector<int> > B) {
  std::vector<std::vector<int> > C = matrix_base::O;
  for (int i = 0; i < matrix_base::size; i++)
    for (int k = 0; k < matrix_base::size; k++)
      for (int j = 0; j < matrix_base::size; j++)
        _fma(C[i][j], A[i][k], B[k][j]);
  return C;
}
std::vector<std::vector<int> > power(
    std::vector<std::vector<int> > x, int y,
    std::vector<std::vector<int> > ans = matrix_base::I) {
  for (; y; y >>= 1, x = x * x)
    if (y & 1) ans = ans * x;
  return ans;
}
int main() {
  scanf("%s", s + 1), n = strlen(s + 1), m = read() + n;
  dp[1][n][0] = 1;
  for (int _ = n; _; _--)
    for (int i = 1, j = _; j <= n; i++, j++)
      for (int k = 0; k <= n - _; k++)
        if (s[i] == s[j]) {
          if (_ <= 2)
            _plus(dp[0][0][k], dp[i][j][k]);
          else
            _plus(dp[i + 1][j - 1][k], dp[i][j][k]);
        } else
          _plus(dp[i][j - 1][k + 1], dp[i][j][k]),
              _plus(dp[i + 1][j][k + 1], dp[i][j][k]);
  init_matrix((3 * n + 1) / 2);
  std::vector<std::vector<int> > G = matrix_base::O;
  G[0][0] = 25;
  for (int i = 1; i < n; i++) G[i][i] = 24;
  for (int i = n; i < (3 * n - 1) / 2; i++) G[i][i] = 25;
  G[(3 * n - 1) / 2][(3 * n - 1) / 2] = 26;
  for (int i = 1; i < n; i++) G[i - 1][i] = 1;
  for (int i = n + 1; i < (3 * n + 1) / 2; i++) G[i - 1][i] = 1;
  for (int i = 0; i < n; i++)
    G[i][(3 * n + 1) / 2 - (n - i + 1) / 2] = dp[0][0][i];
  if (m & 1) {
    int ans = power(G, (m + 1) / 2)[0][(3 * n - 1) / 2];
    std::fill(dp[0][0], dp[0][0] + n, 0);
    for (int i = 2; i <= n; i++)
      if (s[i - 1] == s[i])
        for (int j = 0; j < n; j++) _plus(dp[0][0][j], dp[i - 1][i][j]);
    for (int i = 0; i < n; i++)
      G[i][(3 * n + 1) / 2 - (n - i + 1) / 2] = dp[0][0][i];
    G[(3 * n - 1) / 2][(3 * n - 1) / 2] = 0;
    Write(minus(ans, power(G, (m + 1) / 2)[0][(3 * n - 1) / 2]));
  } else
    Write(power(G, m / 2)[0][(3 * n - 1) / 2]);
  return 0;
}