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;
int gi() {
  int res = 0, w = 1;
  char ch = getchar();
  while (ch != '-' && !isdigit(ch)) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar();
  return res * w;
}
const int Mod = 1e4 + 7;
const int LIM = Mod * Mod;
int cnt;
struct Matrix {
  int m[305][305];
  Matrix() { memset(m, 0, sizeof(m)); }
  int *operator[](const int &id) { return m[id]; }
  Matrix operator*(const Matrix &r) const {
    Matrix res;
    for (int i = 0; i <= cnt; i++)
      for (int j = i; j <= cnt; j++)
        for (int k = i; k <= j; k++) {
          res[i][j] += m[i][k] * r.m[k][j];
          if (res[i][j] >= LIM) res[i][j] %= Mod;
        }
    for (int i = 0; i <= cnt; i++)
      for (int j = i; j <= cnt; j++) res[i][j] %= Mod;
    return res;
  }
} F, G;
void mul(int y) {
  while (y) {
    if (y & 1) F = F * G;
    G = G * G;
    y >>= 1;
  }
}
int N, M, col[205][205], h[205][205][205];
int g[205];
char s[205];
int main() {
  scanf("%s %d", s + 1, &M);
  N = strlen(s + 1);
  h[1][N][0] = 1;
  for (int i = 1; i <= N; i++) {
    for (int j = N; j >= i; j--)
      if (s[i] == s[j]) {
        for (int k = 0; k < i + N - j; k++) {
          if (i + 1 < j)
            h[i + 1][j - 1][k] = (h[i + 1][j - 1][k] + h[i][j][k]) % Mod;
          else
            g[k] = (g[k] + h[i][j][k]) % Mod;
        }
      } else {
        for (int k = 0; k < i + N - j; k++) {
          h[i][j - 1][k + 1] = (h[i][j - 1][k + 1] + h[i][j][k]) % Mod;
          h[i + 1][j][k + 1] = (h[i + 1][j][k + 1] + h[i][j][k]) % Mod;
        }
      }
  }
  cnt = N + (N + 1) / 2 + 1;
  F[0][1] = 1, F[0][N + 1] = g[0], G[cnt][cnt] = 26;
  for (int i = 1; i <= N; i++) {
    int j = cnt - (N - i + 1) / 2;
    G[i][i] = 24, G[i][j] = g[i];
    if (i != N) G[i][i + 1] = 1;
  }
  for (int i = N + 1; i < cnt; i++) G[i][i + 1] = 1, G[i][i] = 25;
  if ((N + M) & 1) {
    mul((N + M + 1) >> 1);
    int ans = F[0][cnt];
    memset(F.m, 0, sizeof(F.m));
    memset(G.m, 0, sizeof(G.m));
    memset(g, 0, sizeof(g));
    for (int i = 1; i < N; i++)
      if (s[i] == s[i + 1]) {
        for (int k = 0; k <= N; k++) g[k] = (g[k] + h[i][i + 1][k]) % Mod;
      }
    F[0][1] = 1, F[0][N + 1] = g[0];
    for (int i = 1; i <= N; i++) {
      int j = cnt - (N - i + 1) / 2;
      G[i][i] = 24, G[i][j] = g[i];
      if (i != N) G[i][i + 1] = 1;
    }
    for (int i = N + 1; i < cnt; i++) G[i][i + 1] = 1, G[i][i] = 25;
    mul((N + M + 1) >> 1);
    printf("%d\n", (ans - F[0][cnt] + Mod) % Mod);
  } else
    mul((N + M) >> 1), printf("%d\n", F[0][cnt]);
  return 0;
}