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 N = 200;
const long long MOD = 10007;
int n;
string s;
int a[2 * N - 1][2 * N - 1], S, ap[2 * N - 1][2 * N - 1], dp[N][N][N + 1];
int tmp[2 * N - 1][2 * N - 1], res[2 * N - 1][2 * N - 1];
long long te[2 * N][2 * N];
void matmul(int a[][2 * N - 1], int b[][2 * N - 1]) {
  for (int i = 0; i < S; i++)
    for (int j = 0; j < S; j++) {
      long long sum = 0;
      for (int k = i; k <= j; k++) sum += a[i][k] * b[k][j];
      te[i][j] = sum % MOD;
    }
  for (int i = 0; i < S; i++)
    for (int j = 0; j < S; j++) a[i][j] = te[i][j];
}
int calc(int lo, int hi, int n24) {
  int& res = dp[lo][hi][n24];
  if (res != -1) return res;
  res = 0;
  if (lo == hi) {
    if (n24 == 0) res = 1;
  } else {
    if (s[lo] == s[hi]) {
      if (lo + 1 == hi) {
        if (n24 == 0) res = 1;
      } else {
        res = calc(lo + 1, hi - 1, n24);
      }
    } else {
      if (n24 > 0) res = calc(lo + 1, hi, n24 - 1) + calc(lo, hi - 1, n24 - 1);
    }
  }
  return res %= MOD;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> s >> n;
  int l = (int)s.size();
  n += l;
  int m = (n + 1) >> 1;
  int N24 = l - 1, N25 = (l + 1) >> 1;
  int N26 = (l + 1) >> 1;
  S = N24 + N25 + N26;
  memset(a, 0, sizeof a);
  for (int i = 0; i < 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 < N24 + N25 - 1) a[i][i + 1] = 1;
      a[i][i + N25] = 1;
    } else
      a[i][i] = 26;
  }
  memcpy(tmp, a, sizeof a);
  memset(res, 0, sizeof res);
  for (int i = 0; i < S; i++) res[i][i] = 1;
  for (int x = m - 1; x; x >>= 1) {
    if (x & 1) matmul(res, a);
    matmul(a, a);
  }
  for (int i = 0; i < S; i++)
    for (int j = 0; j < S; j++) a[i][j] = res[i][j];
  memcpy(ap, a, sizeof a);
  matmul(a, tmp);
  memset(dp, -1, sizeof dp);
  long long ans = 0;
  for (int n26, n25, n24 = 0; n24 <= N24; n24++) {
    n25 = (l - n24 + 1) >> 1;
    bool last25 = !((l - n24) % 2);
    n26 = m - n24 - n25;
    if (n26 < 0) continue;
    int way = calc(0, l - 1, n24);
    ans += way * a[N24 - n24][N24 + N25 + n25 - 1];
    if (n % 2 == 1 && last25)
      ans += MOD * MOD - way * ap[N24 - n24][N24 + n25 - 1];
    ans %= MOD;
  }
  cout << ans % MOD << '\n';
  return 0;
}