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 n, m, cnt, tot, dp[205][205][205], g[205 << 1][205 << 1];
char s[205];
struct matrix {
  int p[205 << 1][205 << 1];
} a, b;
void operator*=(matrix &x, const matrix y) {
  int i, j, k;
  memset(g, 0, sizeof(g));
  for (i = 1; i <= tot; i++)
    for (j = i; j <= tot; j++)
      for (k = j; k <= tot; k++)
        g[i][k] = (g[i][k] + x.p[i][j] * y.p[j][k]) % 10007;
  swap(x.p, g);
}
void ksm(matrix x, int y) {
  int i, j;
  for (i = 1; i <= tot; i++)
    for (j = 1; j <= tot; j++) b.p[i][j] = (i == j);
  for (; y; y >>= 1, x *= x)
    if (y & 1) b *= x;
}
int main() {
  scanf("%s%d", s + 1, &m);
  n = strlen(s + 1);
  m += n;
  int i, j, k;
  for (i = 1; i <= n; i++) {
    dp[i][i][0] = 1;
    if (i < n && s[i] == s[i + 1]) dp[i][i + 1][0] = 1;
  }
  for (i = n - 1; i; i--)
    for (j = (s[i] == s[i + 1]) ? i + 2 : i + 1; j <= n; j++)
      if (s[i] == s[j])
        for (k = 0; k <= n; k++) dp[i][j][k] = dp[i + 1][j - 1][k];
      else
        for (k = 1; k <= n; k++)
          dp[i][j][k] = (dp[i][j - 1][k - 1] + dp[i + 1][j][k - 1]) % 10007;
  int ans = 0;
  cnt = n + 1 >> 1;
  for (i = 1; i < n; i++) {
    a.p[i][i] = 24;
    a.p[i][i + 1] = 1;
  }
  for (i = n; i < n + cnt; i++) {
    a.p[i][i] = 25;
    a.p[i][i + cnt] = a.p[i - 1][i] = 1;
  }
  tot = n + (cnt << 1) - 1;
  for (i = n + cnt; i <= tot; i++) a.p[i][i] = 26;
  ksm(a, m - 1 >> 1);
  a *= b;
  for (i = 0; i < n; i++) {
    j = n - i - 1 >> 1;
    k = a.p[n - i][n + cnt + j];
    if ((m & 1) && !(n - i & 1)) k = (k - b.p[n - i][n + j] + 10007) % 10007;
    ans = (ans + dp[1][n][i] * k) % 10007;
  }
  printf("%d\n", ans);
  return 0;
}