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 Mo = 10007, MAXN = 205;
typedef int Matrix[405][405];
char s[MAXN];
Matrix G, Tmp, Bak;
int F[MAXN][MAXN][MAXN], Sum[MAXN], N, Total, M;
void Multi(Matrix &a, Matrix b) {
  for (int i = 1; i <= Total; i++)
    for (int j = i; j <= Total; j++) {
      Bak[i][j] = 0;
      for (int k = i; k <= j; k++) {
        Bak[i][j] = (Bak[i][j] + a[i][k] * b[k][j] % Mo) % Mo;
      }
    }
  memcpy(a, Bak, sizeof a);
}
void Fast_Multi(int Times) {
  memset(Tmp, 0, sizeof Tmp);
  for (int i = 1; i <= Total; i++) Tmp[i][i] = 1;
  for (; Times; Times >>= 1) {
    if (Times & 1) Multi(Tmp, G);
    Multi(G, G);
  }
}
void Get_Matrix(int Times) {
  memset(G, 0, sizeof G);
  int N24 = M, N25 = (M + 1) / 2;
  Total = N24 + 2 * N25;
  for (int i = 1; i <= N24; i++) G[i][i] = 24;
  for (int i = N24 + 1; i <= N24 + N25; i++)
    G[i][i] = 25, G[i][i + N25] = 1, G[i + N25][i + N25] = 26;
  for (int i = 1; i < N24 + N25; i++) G[i][i + 1] = 1;
  Fast_Multi(Times);
}
int main() {
  scanf("%s%d", s + 1, &N);
  M = strlen(s + 1);
  N += M;
  F[1][M][0] = 1;
  for (int i = 1; i <= M; i++)
    for (int j = M; j >= i; j--)
      for (int n24 = 0; n24 <= M; n24++)
        if (s[i] != s[j]) {
          (F[i + 1][j][n24 + 1] += F[i][j][n24]) %= Mo;
          (F[i][j - 1][n24 + 1] += F[i][j][n24]) %= Mo;
        } else
          (F[i + 1][j - 1][n24] += F[i][j][n24]) %= Mo;
  for (int i = 1; i <= M + 1; i++)
    for (int j = 0; j < i; j++)
      for (int n24 = 0; n24 < M; n24++) (Sum[n24] += F[i][j][n24]) %= Mo;
  Get_Matrix((N + 1) / 2);
  int Ans = 0;
  for (int n24 = 0; n24 < M; n24++)
    (Ans +=
     (Sum[n24] * Tmp[M - n24 + 1][M + (M - n24 + 1) / 2 + (M + 1) / 2])) %= Mo;
  if (N & 1) {
    Get_Matrix((N + 1) / 2 - 1);
    for (int n24 = 0; n24 < M; n24++)
      if ((M - n24) % 2 == 0)
        Ans = (Ans - Sum[n24] * Tmp[M - n24 + 1][M + (M - n24 + 1) / 2] % Mo +
               Mo) %
              Mo;
  }
  printf("%d\n", Ans % Mo);
  return 0;
}