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 maxn = 410, MOD = 10007;
char s[maxn];
int n, m, mat_s;
typedef long long Mat[maxn][maxn];
void print(Mat A) {
  for (int i = 0; i < (mat_s); i++) {
    for (int j = 0; j < (mat_s); j++) {
      cout << A[i][j] << " ";
    }
    cout << endl;
  }
  cout << endl;
}
void mat_mul(Mat A, Mat B, Mat res) {
  static Mat C;
  memset(C, 0, sizeof(C));
  for (int i = 0; i < (mat_s); i++)
    for (int k = (i); k <= (mat_s - 1); k++)
      for (int j = (k); j <= (mat_s - 1); j++) {
        C[i][j] += A[i][k] * B[k][j];
      }
  for (int i = 0; i < (mat_s); i++)
    for (int j = 0; j < (mat_s); j++) {
      C[i][j] %= MOD;
    }
  memcpy(res, C, sizeof(C));
}
void mat_pow(Mat A, long long k, Mat res) {
  static Mat a, r;
  memcpy(a, A, sizeof(a));
  memset(r, 0, sizeof(r));
  for (int i = 0; i < (mat_s); i++) r[i][i] = 1;
  while (k) {
    if (k & 1) {
      mat_mul(r, a, r);
    }
    if (!(k >>= 1)) {
      break;
    }
    mat_mul(a, a, a);
  }
  memcpy(res, r, sizeof(r));
}
int dp[210][210][210];
int rec(int l, int r, int n24) {
  int& res = dp[l][r][n24];
  if (~res) {
    return res;
  }
  if (l == r) {
    return res = !n24;
  }
  if (s[l] == s[r]) {
    if (l + 1 == r) {
      return res = !n24;
    }
    return res = rec(l + 1, r - 1, n24);
  } else {
    if (n24 > 0) {
      return res = (rec(l + 1, r, n24 - 1) + rec(l, r - 1, n24 - 1)) % MOD;
    } else {
      return res = 0;
    }
  }
}
int n24, n25, n26, times;
int mat_at(Mat A, int c24, int c25) {
  int i24 = n24 - c24;
  int i25 = n24 + c25 - 1;
  int i26 = i25 + n25;
  return A[i24][i26];
}
int main() {
  scanf("%s%d", s, &n);
  m = strlen(s);
  n += m;
  times = (n + 1) >> 1;
  n24 = m - 1;
  n26 = n25 = (m + 1) >> 1;
  mat_s = n24 + n25 + n26;
  static Mat A, B;
  for (int i = 0; i < (mat_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;
    }
  }
  mat_pow(A, times - 1, B);
  mat_mul(B, A, A);
  int ans = 0;
  memset(dp, -1, sizeof(dp));
  for (int c24 = 0; c24 < (m); c24++) {
    int c25 = (m - c24 + 1) >> 1;
    if (times - c24 - c25 < 0) {
      continue;
    }
    int ways = rec(0, m - 1, c24);
    ans = (ans + ways * mat_at(A, c24, c25)) % MOD;
    if ((n & 1) && (!((m - c24) & 1))) {
      ans = (ans + MOD - ways * B[n24 - c24][n24 + c25 - 1] % MOD) % MOD;
    }
  }
  printf("%d\n", ans);
  return 0;
}