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>
#pragma comment(linker, "/STACK:1000000000")
using namespace std;
const bool db = false;
string s;
int n, m, n24, n25, n26, len;
int tot;
int a[444][444], c[444][444], aa[444][444];
int res[444][444], res2[444][444];
int dp[222][222][222];
void mul(int a[444][444], int b[444][444]) {
  for (int i = 0; i < tot; ++i) {
    for (int j = 0; j < tot; ++j) {
      long long cur = 0;
      for (int k = i; k <= j; ++k) {
        cur += a[i][k] * b[k][j];
      }
      res[i][j] = cur % 10007;
    }
  }
  for (int i = 0; i < 444; ++i)
    for (int j = 0; j < 444; ++j) a[i][j] = res[i][j];
}
void go(int a[444][444], long long n) {
  memset(res, 0, sizeof(res));
  for (int i = 0; i < 444; ++i) res2[i][i] = 1;
  while (n > 0) {
    if (n & 1) mul(res2, a);
    mul(a, a);
    n >>= 1;
  }
  for (int i = 0; i < 444; ++i)
    for (int j = 0; j < 444; ++j) a[i][j] = res2[i][j];
}
int foo(int L, int R, int n24) {
  if (dp[L][R][n24] != -1) return dp[L][R][n24];
  int &ret = dp[L][R][n24];
  ret = 0;
  if (L == R) {
    ret = n24 == 0;
    return ret;
  }
  if (s[L] == s[R]) {
    if (L + 1 == R) {
      ret = n24 == 0;
    } else {
      ret = foo(L + 1, R - 1, n24);
    }
    return ret;
  }
  if (n24 > 0) {
    ret = (foo(L + 1, R, n24 - 1) + foo(L, R - 1, n24 - 1)) % 10007;
  }
  return ret;
}
int main() {
  cin >> s >> n;
  len = s.length();
  n += len;
  m = (n + 1) / 2;
  n24 = len - 1;
  n25 = n26 = (len + 1) / 2;
  tot = n25 + n26 + n24;
  for (int i = 0; i < tot; ++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;
    }
  }
  for (int i = 0; i < 444; ++i)
    for (int j = 0; j < 444; ++j) aa[i][j] = a[i][j];
  go(a, m - 1);
  for (int i = 0; i < 444; ++i)
    for (int j = 0; j < 444; ++j) c[i][j] = a[i][j];
  mul(a, aa);
  memset(dp, -1, sizeof(dp));
  long long ret = 0;
  for (int nn24 = 0; nn24 < len; ++nn24) {
    int nn25 = (len - nn24 + 1) / 2;
    bool last = (len - nn24) % 2 == 0;
    int nn26 = m - nn24 - nn25;
    if (nn26 < 0) continue;
    ret += foo(0, len - 1, nn24) * a[n24 - nn24][n24 + n25 + nn25 - 1];
    if (n % 2 == 1 && last == true) {
      ret +=
          10007 * 10007 - foo(0, len - 1, nn24) * c[n24 - nn24][n24 + nn25 - 1];
    }
  }
  cout << ret % 10007 << '\n';
  getchar();
  getchar();
  return 0;
}