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 N = 210, M = 310;
int n, m, dp[N][N][N], t[N], ans;
char s[N];
inline void add(int &a, int b) {
  a = ((a + b >= 10007) ? a + b - 10007 : a + b);
}
inline void del(int &a, int b) { a = ((a - b < 0) ? a - b + 10007 : a - b); }
inline void mul(int &a, int b) { a = a * b % 10007; }
inline int m_pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) mul(ans, a);
    b >>= 1;
    mul(a, a);
  }
  return ans;
}
inline int read() {
  int f = 1, x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  return x * f;
}
struct matrix {
  int n, a[M][M];
  inline void clear() { memset(a, 0, sizeof(a)); }
  inline void init() {
    for (int i = 0; i <= n; i++) a[i][i] = 1;
  }
} f;
matrix tr;
matrix operator*(matrix a, matrix b) {
  matrix ans;
  ans.n = a.n;
  ans.clear();
  for (int i = 0; i <= a.n; i++) {
    for (int j = i; j <= a.n; j++) {
      for (int k = i; k <= j; k++)
        add(ans.a[i][j], a.a[i][k] * b.a[k][j] % 10007);
    }
  }
  return ans;
}
matrix operator^(matrix a, int b) {
  matrix ans;
  ans.n = a.n;
  ans.clear();
  ans.init();
  while (b) {
    if (b & 1) ans = ans * a;
    b >>= 1;
    a = a * a;
  }
  return ans;
}
inline void add_edge(int x, int y, int z) { tr.a[x][y] = z; }
signed main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  m = read();
  dp[1][n][0] = 1;
  int lim = (n + 1) / 2;
  for (int i = 1; i <= n; i++) {
    for (int j = n; j >= i; j--) {
      for (int k = 0; k <= n; k++)
        if (dp[i][j][k]) {
          if (s[i] == s[j]) {
            if (j - 1 < i + 1)
              add(t[k], dp[i][j][k]);
            else
              add(dp[i + 1][j - 1][k], dp[i][j][k]);
          } else {
            add(dp[i][j - 1][k + 1], dp[i][j][k]);
            add(dp[i + 1][j][k + 1], dp[i][j][k]);
          }
        }
    }
  }
  for (int i = 0; i < n; i++) {
    if (i != n - 1) add_edge(i, i + 1, 1);
    if (i != 0) add_edge(i, i, 24);
    add_edge(i, n + lim - (n - i + 1) / 2, t[i]);
  }
  for (int i = n; i <= lim + n - 1; i++) {
    add_edge(i, i + 1, 1);
    add_edge(i, i, 25);
  }
  add_edge(lim + n, lim + n, 26);
  f.n = tr.n = lim + n;
  f.a[0][0] = 1;
  f = f * (tr ^ ((n + m + 1) / 2 + 1));
  add(ans, f.a[0][lim + n]);
  if ((n + m) & 1) {
    memset(t, 0, sizeof(t));
    tr.clear();
    f.clear();
    for (int i = 1; i <= n; i++) {
      for (int j = n; j > i; j--)
        if (s[i] == s[j] && j - 1 < i + 1) {
          for (int k = 0; k <= n; k++) add(t[k], dp[i][j][k]);
        }
    }
    for (int i = 0; i < n; i++) {
      if (i != n - 1) add_edge(i, i + 1, 1);
      if (i != 0) add_edge(i, i, 24);
      add_edge(i, n + lim - (n - i + 1) / 2, t[i]);
    }
    for (int i = n; i <= lim + n - 1; i++) {
      add_edge(i, i + 1, 1);
      add_edge(i, i, 25);
    }
    f.n = tr.n = lim + n;
    f.a[0][0] = 1;
    f = f * (tr ^ ((n + m + 1) / 2 + 1));
    del(ans, f.a[0][lim + n]);
  }
  printf("%d\n", ans);
}