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 p = 10007;
int N, L, T, Ans, tr[205], ot[205], A[405], B[405], mtx[405][405],
    tmp[405][405], F[205][205][205];
char s[205];
inline void inc(int& x, int y) {
  if ((x += y) >= p) x -= p;
}
inline void pret() {
  F[0][1][L] = 1;
  for (int _r = L, i = 0; i < _r; ++i)
    for (int _r = L, j = 1; j <= _r; ++j)
      for (int _r = L, k = j; k <= _r; ++k) {
        if (s[j] == s[k]) {
          if (k - 1 < j + 1) {
            if (k == j)
              inc(tr[i], F[i][j][k]);
            else
              inc(ot[i], F[i][j][k]);
          } else
            inc(F[i][j + 1][k - 1], F[i][j][k]);
        } else {
          inc(F[i + 1][j + 1][k], F[i][j][k]);
          inc(F[i + 1][j][k - 1], F[i][j][k]);
        }
      }
}
inline void mul() {
  memcpy(tmp, mtx, sizeof tmp);
  memset(mtx, 0, sizeof mtx);
  for (int _r = T, k = 0; k <= _r; ++k)
    for (int _r = T, i = 0; i <= _r; ++i)
      if (tmp[i][k])
        for (int _r = T, j = 0; j <= _r; ++j)
          if (tmp[k][j]) inc(mtx[i][j], tmp[i][k] * tmp[k][j] % p);
}
inline void prod() {
  memcpy(B, A, sizeof B);
  memset(A, 0, sizeof A);
  for (int _r = T, k = 0; k <= _r; ++k)
    for (int _r = T, i = 0; i <= _r; ++i) inc(A[i], mtx[i][k] * B[k] % p);
}
inline void LUANGAO() {
  memset(A, 0, sizeof A);
  memset(mtx, 0, sizeof mtx);
  for (int _r = L, i = 1; i <= _r; ++i) mtx[i][i] = 24;
  for (int _r = L, i = 0; i < _r; ++i) mtx[L + (L - i + 1 >> 1)][i] = ot[i];
  for (int _r = L, i = 0; i < _r; ++i) mtx[i + 1][i] = 1;
  for (int _r = T, i = L + 2; i < _r; ++i) mtx[i - 1][i] = 1;
  for (int _r = T, i = L + 1; i < _r; ++i) mtx[i][i] = 25;
  mtx[T][L + 1] = 1;
  mtx[T][T] = 26;
  A[0] = 1;
  int xx = (L + N + 1 >> 1);
  for (; xx; xx >>= 1, mul())
    if (xx & 1) prod();
  inc(Ans, A[T] * 26 % p);
}
inline void Build() {
  T = L + (L + 1 >> 1) + 1;
  for (int _r = L, i = 1; i <= _r; ++i) mtx[i][i] = 24;
  for (int _r = L, i = 0; i < _r; ++i)
    mtx[L + (L - i + 1 >> 1)][i] = tr[i] + (N + L & 1 ? 0 : ot[i]);
  for (int _r = L, i = 0; i < _r; ++i) mtx[i + 1][i] = 1;
  for (int _r = T, i = L + 2; i < _r; ++i) mtx[i - 1][i] = 1;
  for (int _r = T, i = L + 1; i < _r; ++i) mtx[i][i] = 25;
  mtx[T][L + 1] = 1;
  mtx[T][T] = 26;
  A[0] = 1;
  int xx = (L + N + 1 >> 1) + 1;
  for (; xx; xx >>= 1, mul())
    if (xx & 1) prod();
  Ans = A[T];
}
int main() {
  scanf("%s%d", s + 1, &N);
  L = strlen(s + 1);
  pret();
  Build();
  if (N + L & 1) LUANGAO();
  printf("%d\n", Ans);
}