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;
typedef int matrix[410][410];
const int p = 10007;
int n, m, f[210][210][210], ans;
char s[210];
matrix a;
void mul(matrix &a, matrix &b, int n) {
  static long long c[410][410];
  memset(c, 0, sizeof(c));
  for (int i = 1; i <= n; ++i)
    for (int k = i; k <= n; ++k)
      if (a[i][k])
        for (int j = k; j <= n; ++j) c[i][j] += a[i][k] * b[k][j];
  for (int i = 1; i <= n; ++i)
    for (int j = i; j <= n; ++j) a[i][j] = c[i][j] % p;
}
void power(matrix &a, int n, int k) {
  static matrix b;
  memset(b, 0, sizeof(b));
  for (int i = 1; i <= n; ++i) b[i][i] = 1;
  for (; k; k >>= 1, mul(a, a, n))
    if (k & 1) mul(b, a, n);
  memcpy(a, b, sizeof(b));
}
int main() {
  scanf("%s%d", s + 1, &m), m += n = strlen(s + 1);
  f[1][n][s[1] != s[n]] = 1;
  for (int i = 1; i <= n; ++i)
    for (int j = n; j >= i; --j)
      for (int k = 0; k <= n - 1; ++k)
        if (f[i][j][k])
          if (s[i] == s[j])
            (f[i + 1][max(j - 1, i)][k + (s[i + 1] != s[j - 1] && i + 1 < j)] +=
             f[i][j][k]) %= p;
          else {
            (f[i + 1][j][k + (s[i + 1] != s[j])] += f[i][j][k]) %= p;
            (f[i][j - 1][k + (s[i] != s[j - 1])] += f[i][j][k]) %= p;
          }
  for (int i = 1; i <= n - 1; ++i) a[i][i] = 24, a[i][i + 1] = 1;
  for (int j = 1; j <= (n + 1) / 2; ++j) {
    a[n + (j - 1) * 2][n + (j - 1) * 2] = 25;
    a[n + (j - 1) * 2 + 1][n + (j - 1) * 2 + 1] = 26;
    a[n + (j - 1) * 2][n + (j - 1) * 2 + 1] = 1;
    a[n + (j - 1) * 2][n + j * 2] = 1;
  }
  power(a, n * 2 + 1, m / 2);
  for (int i = 0; i <= n - 1; ++i) {
    int cnt = 0;
    for (int j = 0; j <= n; ++j) (cnt += f[j + 1][j][i]) %= p;
    if (m & 1) {
      (ans += cnt * a[n - i][n + (n - i + 1) / 2 * 2 - 1] % p * 26) %= p,
          cnt = 0;
      if ((n - 1 - i) & 1) continue;
      for (int j = 1; j <= n; ++j) (cnt += f[j][j][i]) %= p;
      (ans += cnt * a[n - i][n + (n - 1 - i) / 2 * 2]) %= p;
    } else
      (ans += cnt * a[n - i][n + (n - i + 1) / 2 * 2 - 1]) %= p;
  }
  printf("%d\n", ans);
  return 0;
}