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;
template <class T>
inline void rread(T &num) {
  num = 0;
  T f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') num = num * 10 + ch - '0', ch = getchar();
  num *= f;
}
inline int getgcd(int x, int y) {
  if (!x) return y;
  return getgcd(y % x, x);
}
inline int power(int x, int k, int p) {
  int res = 1;
  for (; k; k >>= 1, x = (long long)x * x % p)
    if (k & 1) res = (long long)res * x % p;
  return res;
}
const double pi = acos(-1);
inline void judge() { freopen("input.txt", "r", stdin); }
const int maxn = 4e2 + 5, mod = 1e4 + 7;
int N, N24, N25, N26, l, n;
int f[maxn][maxn][maxn];
char str[maxn];
struct Matrix {
  int a[maxn][maxn];
  inline Matrix() { memset(a, 0, sizeof a); }
  inline void Set(int i, int j, int k) { a[i][j] = k; }
  inline friend Matrix operator*(Matrix A, Matrix B) {
    Matrix C;
    for (int(i) = (1); (i) <= (N); (i)++)
      for (int(j) = (i); (j) <= (N); (j)++)
        for (int(k) = (i); (k) <= (j); (k)++)
          C.a[i][j] = (C.a[i][j] + A.a[i][k] * B.a[k][j]) % mod;
    return C;
  }
  inline friend Matrix Power(Matrix A, int k) {
    Matrix B;
    for (int(i) = (1); (i) <= (N); (i)++) B.Set(i, i, 1);
    for (; k; k >>= 1, A = A * A) {
      if (k & 1) B = B * A;
    }
    return B;
  }
  inline int Get(int i, int j) { return a[i][j]; }
} AM, M1, M2;
inline int DP(int l, int r, int n24) {
  int &res = f[l][r][n24];
  if (res != -1) return res;
  res = 0;
  if (l == r) {
    if (n24 == 0) res = 1;
  } else {
    if (str[l] == str[r]) {
      if (l + 1 == r) {
        if (!n24) res = 1;
      } else
        res = DP(l + 1, r - 1, n24);
    } else if (n24)
      res = DP(l + 1, r, n24 - 1) + DP(l, r - 1, n24 - 1);
  }
  return res %= mod;
}
inline void filein() {
  freopen("B.in", "r", stdin);
  freopen("B.out", "w", stdout);
}
int main() {
  scanf("%s", str + 1);
  l = strlen(str + 1);
  rread(n);
  n = n + l;
  N24 = l - 1;
  N25 = N26 = (l + 1) / 2;
  N = N24 + N25 + N26;
  for (int(i) = (1); (i) <= (N24); (i)++) AM.a[i][i] = 24, AM.a[i][i + 1] = 1;
  for (int(i) = (N24 + 1); (i) <= (N24 + N25); (i)++) {
    AM.a[i][i] = 25;
    if (i != N24 + N25) AM.a[i][i + 1] = 1;
    AM.a[i][i + N25] = 1;
  }
  for (int(i) = (N24 + N25 + 1); (i) <= (N24 + N25 + N26); (i)++)
    AM.a[i][i] = 26;
  M1 = Power(AM, (n + 1) / 2 - 1);
  M2 = M1 * AM;
  memset(f, -1, sizeof f);
  int ans = 0;
  for (int(n24) = (0); (n24) <= (l - 1); (n24)++) {
    int n25 = (l - n24 + 1) / 2;
    int n26 = (n + 1) / 2 - n24 - n25;
    if (n26 < 0) continue;
    int weight = DP(1, l, n24);
    ans = (ans + weight * M2.Get(N24 - n24 + 1, N24 + N25 + n25)) % mod;
    if ((n & 1) && !((l - n24) & 1))
      ans =
          ((ans - weight * M1.Get(N24 - n24 + 1, N24 + n25)) % mod + mod) % mod;
  }
  printf("%d\n", ans);
  return 0;
}