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;
int power(int x, int t) {
  int ret = 1;
  while (t > 0) {
    if (t & 1) ret = 1LL * ret * x % MOD;
    x = 1LL * x * x % MOD;
    t >>= 1;
  }
  return ret;
}
int n, m;
char ch[205];
int dp[205][205][605];
int od[605], ev[605];
int fra[605];
void mul1(int cur[], int x) {
  for (int i = 604; i >= 1; i--)
    cur[i] = (cur[i] + 1LL * (MOD - x) * cur[i - 1]) % MOD;
}
void div1(int cur[], int x) {
  for (int i = 1; i <= (int)(604); i++)
    cur[i] = (cur[i] + 1LL * x * cur[i - 1]) % MOD;
}
void add(int cur[], int from[], int x, int y) {
  for (int i = 0; i < (int)(605 - y); i++)
    cur[i + y] = (cur[i + y] + 1LL * from[i] * x) % MOD;
}
int ccf[405], csp[805];
int solve(int cur[], int d) {
  if (d < 605) return cur[d];
  int deg = 2 * n + 1, pos = 605 - deg;
  d -= pos;
  for (int i = 0; i < (int)(deg); i++) ccf[i] = 0;
  ccf[0] = 1;
  for (int i = 29; i >= 0; i--) {
    for (int j = 0; j < (int)(deg * 2); j++) csp[j] = 0;
    for (int j = 0; j < (int)(deg); j++)
      for (int k = 0; k < (int)(deg); k++)
        csp[j + k + (d >> i & 1)] =
            (csp[j + k + (d >> i & 1)] + 1LL * ccf[j] * ccf[k]) % MOD;
    for (int j = deg * 2 - 1; j >= deg; j--) {
      for (int k = 1; k <= (int)(deg); k++)
        csp[j - k] = (csp[j - k] + 1LL * (MOD - csp[j]) * fra[k]) % MOD;
      csp[j] = 0;
    }
    for (int j = 0; j < (int)(deg); j++) ccf[j] = csp[j];
  }
  int ret = 0;
  for (int i = 0; i < (int)(deg); i++)
    ret = (ret + 1LL * cur[i + pos] * ccf[i]) % MOD;
  return ret;
}
int main() {
  scanf("%s%d", ch + 1, &m);
  n = strlen(ch + 1);
  m += n;
  dp[0][n + 1][0] = 1;
  for (int i = 0; i <= n; i++)
    for (int j = n + 1; j - i >= 2; j--)
      if (ch[i + 1] == ch[j - 1]) {
        div1(dp[i][j], 25);
        add(dp[i + 1][j - 1], dp[i][j], 1, 1);
      } else {
        div1(dp[i][j], 24);
        add(dp[i + 1][j], dp[i][j], 1, 1);
        add(dp[i][j - 1], dp[i][j], 1, 1);
      }
  for (int i = 0; i <= n; i++)
    for (int j = min(n + 1, i + 2); j >= i; j--)
      if (j - i == 2)
        add(od, dp[i][j], 1, 0);
      else {
        div1(dp[i][j], 26);
        add(ev, dp[i][j], 1, 0);
        add(od, dp[i][j], 26, 0);
      }
  fra[0] = 1;
  for (int i = 0; i < (int)(n); i++) mul1(fra, 24);
  for (int i = 0; i < (int)(n); i++) mul1(fra, 25);
  mul1(fra, 26);
  int ans = m % 2 == 0 ? solve(ev, m / 2) : solve(od, (m - 1) / 2);
  printf("%d\n", ans);
  return 0;
}