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;
namespace red {
inline int read() {
  int x = 0;
  char ch, f = 1;
  for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar())
    ;
  if (ch == '-') f = 0, ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return f ? x : -x;
}
const int N = 3e5 + 10, p = 1e4 + 7;
char s[2000];
int n, m, up;
int f[210][210][210], g[210];
struct matrix {
  int a[310][310];
  int *operator[](const int &t) { return a[t]; }
  matrix() { memset(a, 0, sizeof(a)); }
  inline matrix operator*(const matrix &t) const {
    matrix ret;
    for (int i = 0; i <= up; ++i) {
      for (int j = i; j <= up; ++j) {
        for (int k = 1; k <= j; ++k) {
          (ret.a[i][j] += a[i][k] * t.a[k][j] % p) %= p;
        }
      }
    }
    return ret;
  }
  inline matrix operator^(int k) const {
    matrix ret, x = *this;
    for (int i = 0; i <= up; ++i) ret.a[i][i] = 1;
    while (k) {
      if (k & 1) ret = ret * x;
      x = x * x;
      k >>= 1;
    }
    return ret;
  }
} S, T;
inline void main() {
  scanf("%s", s);
  n = strlen(s);
  m = read();
  f[0][n - 1][0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = n - 1; j >= i; --j) {
      if (s[i] == s[j]) {
        for (int k = 0; k < i + n - j; ++k) {
          if (i + 1 < j)
            (f[i + 1][j - 1][k] += f[i][j][k]) %= p;
          else
            g[k] = (g[k] + f[i][j][k]) % p;
        }
      } else {
        for (int k = 0; k < i + n - j; ++k) {
          (f[i + 1][j][k + 1] += f[i][j][k]) %= p;
          (f[i][j - 1][k + 1] += f[i][j][k]) %= p;
        }
      }
    }
  }
  up = n + (n + 1) / 2 + 1;
  S[0][1] = 1, S[0][up - (n + 1) / 2] = g[0], T[up][up] = 26;
  for (int i = 1; i <= n; ++i) {
    T[i][i] = 24, T[i][up - (n - i + 1) / 2] = g[i];
    if (i != n) T[i][i + 1] = 1;
  }
  for (int i = n + 1; i < up; ++i) T[i][i + 1] = 1, T[i][i] = 25;
  if ((n + m) & 1) {
    T = T ^ ((n + m + 1) >> 1);
    S = S * T;
    int ans = S[0][up];
    memset(S.a, 0, sizeof(S.a));
    memset(T.a, 0, sizeof(T.a));
    memset(g, 0, sizeof(g));
    for (int i = 0; i < n - 1; ++i)
      if (s[i] == s[i + 1]) {
        for (int k = 0; k <= n; ++k) {
          (g[k] += f[i][i + 1][k]) %= p;
        }
      }
    S[0][1] = 1, S[0][up - (n + 1) / 2] = g[0];
    for (int i = 1; i <= n; ++i) {
      T[i][i] = 24, T[i][up - (n - i + 1) / 2] = g[i];
      if (i != n) T[i][i + 1] = 1;
    }
    for (int i = n + 1; i < up; ++i) T[i][i + 1] = 1, T[i][i] = 25;
    T = T ^ ((n + m + 1) >> 1);
    S = S * T;
    printf("%d\n", (ans - S[0][up] + p) % p);
  } else {
    T = T ^ ((n + m + 1) >> 1);
    S = S * T;
    printf("%d\n", S[0][up]);
  }
}
}  // namespace red
signed main() {
  red::main();
  return 0;
}