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 MOD = 10007;
const int L = 200;
const int MS = 400;
inline void add(int& a, int b) {
  a += b;
  if (a >= MOD) {
    a -= MOD;
  }
  if (a < 0) {
    a += MOD;
  }
}
int dp[L][L][L + 1];
char s[L];
int f(int left, int right, int n24) {
  int& res = dp[left][right][n24];
  if (res != -1) return res;
  res = 0;
  if (left == right) {
    if (n24 == 0) {
      res = 1;
    }
  } else {
    if (s[left] == s[right]) {
      if (left + 1 == right) {
        if (n24 == 0) {
          res = 1;
        }
      } else {
        res = f(left + 1, right - 1, n24);
      }
    } else {
      if (n24 > 0) {
        res = f(left, right - 1, n24 - 1) + f(left + 1, right, n24 - 1);
        if (res >= MOD) {
          res -= MOD;
        }
      }
    }
  }
  return res;
}
int S;
int A[MS][MS];
int _A[MS][MS];
int B[MS][MS];
int C[MS][MS];
int work[MS][MS];
void matmul(int a[][MS], int b[][MS]) {
  memset(work, 0, sizeof(work));
  int i, j, k;
  for ((i) = 0; (i) < (int)(S); (i)++) {
    for ((j) = 0; (j) < (int)(S); (j)++) {
      int val = 0;
      for (k = i; k < j + 1; ++k) {
        add(val, a[i][k] * b[k][j] % MOD);
      }
      work[i][j] = val;
    }
  }
  for ((i) = 0; (i) < (int)(S); (i)++) {
    for ((j) = 0; (j) < (int)(S); (j)++) {
      work[i][j] %= MOD;
      a[i][j] = work[i][j];
    }
  }
}
void matpow(int a[][MS], long long n) {
  int i, j;
  memset(B, 0, sizeof(B));
  for ((i) = 0; (i) < (int)(S); (i)++) B[i][i] = 1;
  while (n) {
    if (n & 1) {
      matmul(B, a);
    }
    matmul(a, a);
    n >>= 1;
  }
  for ((i) = 0; (i) < (int)(S); (i)++)
    for ((j) = 0; (j) < (int)(S); (j)++) a[i][j] = B[i][j];
}
int MAIN() {
  long long n, m;
  scanf("%s", s);
  scanf("%lld", &n);
  int l = (int)strlen(s);
  n += l;
  m = (n + 1) / 2;
  int N24 = l - 1;
  int N25 = (l + 1) / 2;
  int N26 = N25;
  S = N24 + N25 + N26;
  int i, j;
  for ((i) = 0; (i) < (int)(S); (i)++)
    for ((j) = 0; (j) < (int)(S); (j)++) A[i][j] = 0;
  for ((i) = 0; (i) < (int)(S); (i)++) {
    if (i < N24) {
      A[i][i] = 24;
      A[i][i + 1] = 1;
    } else if (i < N24 + N25) {
      A[i][i] = 25;
      if (i + 1 < N24 + N25) A[i][i + 1] = 1;
      A[i][i + N25] = 1;
    } else {
      A[i][i] = 26;
    }
  }
  for ((i) = 0; (i) < (int)(S); (i)++)
    for ((j) = 0; (j) < (int)(S); (j)++) _A[i][j] = A[i][j];
  matpow(A, m - 1);
  for ((i) = 0; (i) < (int)(S); (i)++)
    for ((j) = 0; (j) < (int)(S); (j)++) C[i][j] = A[i][j];
  matmul(A, _A);
  memset(dp, -1, sizeof(dp));
  int ans = 0, n24;
  for ((n24) = 0; (n24) < (int)(l); (n24)++) {
    int n25 = (l - n24 + 1) / 2;
    int n26 = m - n24 - n25;
    if (n26 < 0) continue;
    bool flag = ((l - n24) % 2 == 0);
    int val = f(0, l - 1, n24);
    add(ans, val * A[N24 - n24][N24 + N25 + n25 - 1] % MOD);
    if (n % 2 == 1 && flag) {
      add(ans, (MOD * MOD - val * C[N24 - n24][N24 + n25 - 1]) % MOD);
    }
  }
  printf("%d\n", ans);
  return 0;
}
int main() {
  ios ::sync_with_stdio(false);
  cout << fixed << setprecision(16);
  return MAIN();
}