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 RLEN = 1 << 20 | 1;
inline char gc() {
  static char ibuf[RLEN], *ib, *ob;
  (ib == ob) && (ob = (ib = ibuf) + fread(ibuf, 1, RLEN, stdin));
  return (ib == ob) ? EOF : *ib++;
}
inline int read() {
  char ch = gc();
  int res = 0;
  bool f = 1;
  while (!isdigit(ch)) f ^= ch == '-', ch = gc();
  while (isdigit(ch)) res = (res + (res << 2) << 1) + (ch ^ 48), ch = gc();
  return f ? res : -res;
}
inline int readstring(char *s) {
  int top = 0;
  char ch = gc();
  while (isspace(ch)) ch = gc();
  while (!isspace(ch) && ch != EOF) s[++top] = ch, ch = gc();
  return top;
}
template <class tp>
inline void chemx(tp &a, tp b) {
  a < b ? a = b : 0;
}
template <class tp>
inline void chemn(tp &a, tp b) {
  a > b ? a = b : 0;
}
const int mod = 10007;
inline int add(int a, int b) { return (a += b) >= mod ? (a - mod) : a; }
inline int dec(int a, int b) {
  a -= b;
  return a + (a >> 31 & mod);
}
inline int mul(int a, int b) {
  a *= b;
  return (a >= mod) ? (a % mod) : a;
}
inline void Add(int &a, int b) { (a += b) >= mod ? (a -= mod) : 0; }
inline void Dec(int &a, int b) { a -= b, a += a >> 31 & mod; }
inline void Mul(int &a, int b) {
  a *= b;
  a = (a >= mod) ? (a % mod) : a;
}
inline int ksm(int a, int b, int res = 1) {
  if (a == 0 && b == 0) return 0;
  for (; b; b >>= 1, Mul(a, a)) (b & 1) && (Mul(res, a), 1);
  return res;
}
inline int Inv(int x) { return ksm(x, mod - 2); }
inline int fix(int x) { return (x < 0) ? x + mod : x; }
const int N = 405;
int lim;
struct mat {
  int a[N][N];
  mat() { memset(a, 0, sizeof(a)); }
  friend inline mat operator*(const mat &a, const mat &b) {
    static long long tp[N][N];
    mat c;
    for (int i = 1; i <= lim; i++)
      for (int k = i; k <= lim; k++)
        for (int j = k, v = a.a[i][k]; j <= lim; j++)
          tp[i][j] += (long long)v * b.a[k][j];
    for (int i = 1; i <= lim; i++)
      for (int j = 1; j <= lim; j++) c.a[i][j] = tp[i][j] % mod, tp[i][j] = 0;
    return c;
  }
  friend inline mat operator^(mat a, int b) {
    mat res;
    for (int i = 1; i <= lim; i++) res.a[i][i] = 1;
    for (; b; b >>= 1, a = a * a)
      if (b & 1) res = res * a;
    return res;
  }
} bas, res;
int n, m, n1, n2, n3;
int f[201][201][201];
char s[N];
int dfs(int x, int l, int r) {
  if (~f[x][l][r]) return f[x][l][r];
  int res = 0;
  if (l == r)
    res = (x == 0);
  else if (s[l] == s[r]) {
    if (l + 1 == r)
      res = (x == 0);
    else
      res = dfs(x, l + 1, r - 1);
  } else if (x > 0)
    res = add(dfs(x - 1, l + 1, r), dfs(x - 1, l, r - 1));
  return f[x][l][r] = res;
}
int main() {
  n = readstring(s), m = read() + n, n1 = n - 1, n2 = n3 = (n + 1) / 2;
  lim = n1 + n2 + n3, memset(f, -1, sizeof(f));
  for (int i = 1; i <= n1; i++) bas.a[i][i] = 24, bas.a[i][i + 1] = 1;
  for (int i = n1 + 1; i <= n1 + n2; i++)
    bas.a[i][i] = 25, bas.a[i - 1][i] = 1, bas.a[i][i + n2] = 1;
  for (int i = n1 + n2 + 1; i <= lim; i++) bas.a[i][i] = 26;
  res = bas ^ ((m + 1) / 2 - 1), bas = res * bas;
  int ans = 0;
  for (int l1 = 0; l1 <= n1; l1++) {
    int l2 = (n - l1 + 1) / 2;
    Add(ans, mul(dfs(l1, 1, n), bas.a[n1 - l1 + 1][n1 + n2 + l2]));
    if ((m & 1) && ((n - l1) % 2 == 0))
      Dec(ans, mul(dfs(l1, 1, n), res.a[n1 - l1 + 1][n1 + l2]));
  }
  cout << ans << '\n';
  return 0;
}