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>
const unsigned int Mod = 10007;
const int ML = 205, MS = 305;
inline void Add(unsigned int &x, unsigned int y) {
  x -= (x += y) >= Mod ? Mod : 0;
}
int D;
struct Mat {
  unsigned int A[MS][MS];
  Mat() { memset(A, 0, sizeof A); }
  Mat(int x) {
    memset(A, 0, sizeof A);
    for (int i = 1; i <= D; ++i) A[i][i] = x;
  }
  void operator*=(Mat B) {
    static int C[MS][MS];
    for (int i = 1; i <= D; ++i)
      for (int j = 1; j <= i; ++j) C[i][j] = A[i][j], A[i][j] = 0;
    for (int i = 1; i <= D; ++i) {
      for (int k = 1; k <= i; ++k)
        for (int j = 1; j <= k; ++j) {
          A[i][j] += C[i][k] * B.A[k][j];
          if (A[i][j] >= 4194847260) A[i][j] %= Mod;
        }
      for (int j = 1; j <= i; ++j) A[i][j] %= Mod;
    }
  }
  friend Mat operator^(Mat B, int e) {
    Mat A(1);
    for (; e; e >>= 1, B *= B)
      if (e & 1) A *= B;
    return A;
  }
} A;
int N, L, G;
char S[ML];
unsigned int f[ML][ML][ML], g[ML], Ans;
int main() {
  scanf("%s%d", S + 1, &N), N += L = strlen(S + 1);
  f[1][L][0] = 1;
  for (int q = L; q >= 1; --q) {
    for (int i = 1; i <= L - q + 1; ++i) {
      int j = i + q - 1, t = S[i] != S[j];
      if (t) {
        for (int x = 0; x < L; ++x)
          Add(f[i + 1][j][x + 1], f[i][j][x]),
              Add(f[i][j - 1][x + 1], f[i][j][x]);
      } else {
        unsigned int *v = i + 2 <= j ? f[i + 1][j - 1] : g;
        for (int x = 0; x < L; ++x) Add(v[x], f[i][j][x]);
      }
    }
  }
  G = (L - 1) / 2 + 1, D = L + G + 1;
  for (int i = 1; i <= D; ++i) {
    if (i <= L) {
      if (i > 1) A.A[i][i] = 24;
      A.A[L + G - (L - i) / 2][i] = g[i - 1];
      if (i < L) A.A[i + 1][i] = 1;
    } else if (i < D) {
      A.A[i][i] = 25;
      A.A[i + 1][i] = 1;
    } else
      A.A[i][i] = 26;
  }
  Ans = (N & 1 ? 26 : 1) * (A ^ (N / 2 + 1)).A[D][1];
  if (N & 1) {
    for (int i = 1; i <= L; ++i) {
      A.A[L + G - (L - i) / 2][i] = 0;
      for (int j = 1; j <= L; ++j)
        Add(A.A[L + G - (L - i) / 2][i], f[j][j][i - 1]);
    }
    Add(Ans, (A ^ (N / 2 + 1)).A[D - 1][1]);
  }
  printf("%d\n", Ans % Mod);
  return 0;
}