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 maxn = 310;
const int Mod = 1e4 + 7;
int n, m, len, h[maxn][maxn][maxn];
bool vis[maxn][maxn][maxn];
char s[maxn];
struct Matrix {
  int a[maxn][maxn];
} f, g;
Matrix operator*(Matrix a, Matrix b) {
  Matrix c;
  for (int i = (1), _end_ = (len); i <= _end_; ++i)
    for (int j = (i), _end_ = (len); j <= _end_; ++j) {
      c.a[i][j] = 0;
      for (int k = (i), _end_ = (j); k <= _end_; ++k)
        c.a[i][j] = (c.a[i][j] + a.a[i][k] * b.a[k][j]) % Mod;
    }
  return c;
}
inline void power(int n) {
  Matrix h = g;
  --n;
  int a[maxn];
  while (n) {
    if (n & 1) h = h * g;
    g = g * g;
    n >>= 1;
  }
  for (int i = (1), _end_ = (len); i <= _end_; ++i) a[i] = 0;
  for (int i = (1), _end_ = (len); i <= _end_; ++i)
    for (int j = (1), _end_ = (len); j <= _end_; ++j)
      a[j] = (a[j] + f.a[i][i] * h.a[i][j]) % Mod;
  for (int i = (1), _end_ = (len); i <= _end_; ++i) f.a[i][i] = a[i];
}
inline int DFS(int l, int r, int x) {
  if (x < 0) return 0;
  if (vis[l][r][x]) return h[l][r][x];
  vis[l][r][x] = true;
  if (l == 1 && r == m) h[l][r][x] = !x;
  if (l > 1 && s[l - 1] != s[r]) h[l][r][x] += DFS(l - 1, r, x - 1);
  if (r < m && s[l] != s[r + 1]) h[l][r][x] += DFS(l, r + 1, x - 1);
  if (l > 1 && r < m && s[l - 1] == s[r + 1])
    h[l][r][x] += DFS(l - 1, r + 1, x);
  h[l][r][x] %= Mod;
  return h[l][r][x];
}
int main() {
  scanf("%s", s + 1);
  m = strlen(s + 1);
  scanf("%d", &n);
  len = m + (m + 1) / 2;
  for (int i = (0), _end_ = (m - 1); i <= _end_; ++i) {
    int num = (m - i + 1) / 2, sum = 0;
    for (int j = (1), _end_ = (m); j <= _end_; ++j) {
      sum += DFS(j, j, i);
      if (j < m && s[j] == s[j + 1]) sum += DFS(j, j + 1, i);
    }
    if (!i)
      f.a[m][m] = sum;
    else {
      g.a[i][len - num] = sum;
      g.a[i][i] = 24;
      if (i != 1)
        g.a[i - 1][i] = 1;
      else
        f.a[i][i] = 1;
    }
  }
  for (int i = (m), _end_ = (len - 1); i <= _end_; ++i) {
    g.a[i][i + 1] = 1;
    g.a[i][i] = 25;
  }
  g.a[len][len] = 26;
  power((n + m + 1) / 2);
  if (!((n + m) & 1)) {
    printf("%d\n", f.a[len][len]);
    return 0;
  }
  int ans = f.a[len][len];
  memset((f.a), 0, sizeof(f.a));
  memset((g.a), 0, sizeof(g.a));
  for (int i = (0), _end_ = (m - 1); i <= _end_; ++i) {
    int num = (m - i + 1) / 2, sum = 0;
    for (int j = (1), _end_ = (m); j <= _end_; ++j)
      if (j < m && s[j] == s[j + 1]) sum += DFS(j, j + 1, i);
    if (!i)
      f.a[m][m] = sum;
    else {
      g.a[i][len - num] = sum;
      g.a[i][i] = 24;
      if (i != 1)
        g.a[i - 1][i] = 1;
      else
        f.a[i][i] = 1;
    }
  }
  for (int i = (m), _end_ = (len - 1); i <= _end_; ++i) {
    g.a[i][i + 1] = 1;
    g.a[i][i] = 25;
  }
  power((n + m + 1) / 2);
  ans -= f.a[len][len];
  printf("%d\n", (ans + Mod) % Mod);
  return 0;
}