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 sj = 205;
const int zzh = 10007;
int dp[sj][sj][sj], tp, d, m, hf, n, bz, ans;
char s[sj];
struct matrix {
  int a[405][405];
  inline void clear() { memset(a, 0, sizeof(a)); }
  friend matrix operator*(matrix x, matrix y) {
    matrix ret;
    ret.clear();
    for (register int i = 1; i <= d; i++)
      for (register int j = i; j <= d; j++)
        for (register int k = i; k <= j; k++)
          ret.a[i][j] = (ret.a[i][j] + x.a[i][k] * y.a[k][j]) % zzh;
    return ret;
  }
} nt, res, qwq;
void build() {
  hf = (m + 1) / 2, d = hf * 2 + m - 1;
  for (int i = 1; i < m - 1 + hf; i++) nt.a[i][i + 1] = 1;
  for (int i = m; i <= m - 1 + hf; i++) nt.a[i][i + hf] = 1;
  for (int i = 1; i < m; i++) nt.a[i][i] = 24;
  for (int i = m; i <= m - 1 + hf; i++) nt.a[i][i] = 25;
  for (int i = m + hf; i <= d; i++) nt.a[i][i] = 26;
}
int dfs(int l, int r, int k) {
  if (k < 0) return 0;
  if (l == r || l == r + 1) {
    if (k == 0)
      return dp[l][r][k] = 1;
    else
      return dp[l][r][k] = 0;
  }
  if (dp[l][r][k] != -1) return dp[l][r][k];
  if (s[l] == s[r])
    dp[l][r][k] = dfs(l + 1, r - 1, k);
  else
    dp[l][r][k] = dfs(l + 1, r, k - 1) + dfs(l, r - 1, k - 1);
  if (dp[l][r][k] >= zzh) dp[l][r][k] -= zzh;
  return dp[l][r][k];
}
int main() {
  scanf("%s%d", s + 1, &n);
  m = strlen(s + 1), n += m;
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < m; i++) dfs(1, m, i);
  for (int i = 1; i <= m; i++) build();
  bz = n / 2;
  for (int i = 1; i <= d; i++) qwq.a[i][i] = 1;
  while (bz) {
    if (bz & 1) qwq = qwq * nt;
    nt = nt * nt, bz >>= 1;
  }
  for (int i = 0; i < m; i++) {
    bz = (m - i + 1) / 2;
    ans = (ans + dp[1][m][i] * qwq.a[m - i][m + hf + bz - 1]) % zzh;
  }
  if (n & 1) {
    ans = ans * 26 % zzh;
    for (int i = 0; i < m; i++) {
      if (!((m - i) & 1)) continue;
      bz = (m - i + 1) / 2;
      ans = (ans + dp[1][m][i] * qwq.a[m - i][m + bz - 1]) % zzh;
    }
  }
  printf("%d", ans);
  return 0;
}