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;
int mod = 10007;
struct mat {
  int num[410][410];
  int n;
  mat(int _n = 0) {
    memset(num, 0, sizeof(num));
    n = _n;
  }
  friend mat operator*(mat &a, mat &b) {
    mat res(a.n);
    for (int i = 0; i < a.n; i++) {
      for (int j = 0; j < a.n; j++) {
        long long tmp = 0;
        for (int k = i; k <= j; k++) {
          tmp += a.num[i][k] * b.num[k][j];
        }
        res.num[i][j] = tmp % mod;
      }
    }
    return res;
  }
  friend mat operator^(mat a, int b) {
    mat t = a, res(a.n);
    for (int i = 0; i < res.n; i++) res.num[i][i] = 1;
    while (b) {
      if (b & 1) res = res * t;
      b >>= 1;
      t = t * t;
    }
    return res;
  }
};
char s[210];
int dp[210][210][210];
int n, len, m;
int n24, n25, n26;
int calc(int i, int j, int k) {
  int &res = dp[i][j][k];
  if (res != -1) return res;
  res = 0;
  if (i == j) {
    if (k == 0) res = 1;
  } else {
    if (s[i] == s[j]) {
      if (i + 1 == j) {
        if (k == 0) res = 1;
      } else {
        res = calc(i + 1, j - 1, k);
      }
    } else {
      if (k) {
        res = (calc(i + 1, j, k - 1) + calc(i, j - 1, k - 1)) % mod;
      }
    }
  }
  return res;
}
int main() {
  scanf("%s", s);
  scanf("%d", &n);
  len = strlen(s);
  n += len;
  n24 = len - 1;
  n25 = n26 = (len + 1) / 2;
  m = n24 + n25 + n26;
  mat trans(m);
  for (int i = 0; i < m; i++) {
    if (i < n24) {
      trans.num[i][i] = 24;
      trans.num[i][i + 1] = 1;
    } else if (i < n24 + n25) {
      trans.num[i][i] = 25;
      if (i < n24 + n25 - 1) trans.num[i][i + 1] = 1;
      trans.num[i][i + n25] = 1;
    } else
      trans.num[i][i] = 26;
  }
  mat trans1 = trans ^ ((n + 1) / 2 - 1);
  mat trans2 = trans1 * trans;
  int ans = 0;
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < len; i++) {
    int j = (len - i + 1) / 2;
    int k = (n + 1) / 2 - i - j;
    if (k < 0) continue;
    int coe = calc(0, len - 1, i);
    ans += coe * trans2.num[n24 - i][n24 + n25 + j - 1];
    if (n % 2 == 1 && (len - i) % 2 == 0)
      ans -= coe * trans1.num[n24 - i][n24 + j - 1];
    ans = (ans % mod + mod) % mod;
  }
  printf("%d\n", ans);
  return 0;
}