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;
char s[510];
int m, len, n, f[210][210][510], t1, t2, t3, tot, ans;
struct Matrix {
  int r, c;
  int a[510][510];
  void clean() { memset(a, 0, sizeof(a)); }
} A, c, t;
int DFS(int l, int r, int x) {
  int res = 0;
  if (f[l][r][x] != -1) return f[l][r][x];
  if (l == r)
    res = (x == 0);
  else {
    if (s[l] == s[r]) {
      if (l + 1 == r)
        res = (x == 0);
      else
        res = DFS(l + 1, r - 1, x);
    } else {
      if (x > 0) res = (DFS(l + 1, r, x - 1) + DFS(l, r - 1, x - 1)) % 10007;
    }
  }
  f[l][r][x] = res;
  return res;
}
Matrix operator*(Matrix A, Matrix B) {
  Matrix res;
  res.clean();
  res.c = A.c, res.r = B.r;
  for (int i = 1; i <= A.c; i++)
    for (int j = 1; j <= B.r; j++) {
      long long mem = 0;
      for (int k = i; k <= j; k++) mem = mem + A.a[i][k] * B.a[k][j];
      res.a[i][j] = mem % 10007;
    }
  return res;
}
Matrix Mqpow(Matrix b, int x) {
  Matrix mem, res;
  mem.clean();
  res.clean();
  res.r = tot, res.c = tot;
  mem.r = tot, mem.c = tot;
  for (int i = 1; i <= tot; i++) res.a[i][i] = 1, mem.a[i][i] = 1;
  mem = mem * b;
  while (x) {
    if (x & 1) res = res * mem;
    x >>= 1;
    mem = mem * mem;
  }
  return res;
}
int main() {
  memset(f, -1, sizeof(f));
  scanf("%s", s + 1);
  scanf("%d", &n);
  len = strlen(s + 1);
  n += len;
  m = (n + 1) / 2;
  t1 = len - 1, t2 = (len + 1) / 2, t3 = t2;
  tot = t1 + t2 + t3;
  A.r = tot, A.c = tot;
  for (int i = 1; i <= t1; i++) A.a[i][i] = 24, A.a[i][i + 1] = 1;
  for (int i = t1 + 1; i <= t1 + t2; i++) {
    A.a[i][i] = 25, A.a[i][i + t2] = 1;
    if (i < t1 + t2) A.a[i][i + 1] = 1;
  }
  for (int i = t1 + t2 + 1; i <= tot; i++) A.a[i][i] = 26;
  t.r = tot, t.c = tot, c.r = tot, c.c = tot;
  for (int i = 1; i <= tot; i++)
    for (int j = 1; j <= tot; j++) t.a[i][j] = A.a[i][j];
  A = Mqpow(A, m - 1);
  for (int i = 1; i <= tot; i++)
    for (int j = 1; j <= tot; j++) c.a[i][j] = A.a[i][j];
  A = A * t;
  for (int i = 0; i <= t1; i++) {
    int j = (len - i + 1) / 2;
    int k = m - i - j;
    if (k < 0) continue;
    int t = DFS(1, len, i);
    ans = (ans + t * A.a[t1 - i + 1][t1 + t2 + j]) % 10007;
    if ((n & 1) && (len - i) % 2 == 0)
      ans = (ans - (t * c.a[t1 - i + 1][t1 + j]) % 10007 + 10007) % 10007;
  }
  printf("%d\n", ans);
  return 0;
}