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>
const int N = 405, P = 10007;
int r, f[N][N][N], x[N][N];
char str[N];
void inc(int& a, int b) { a += b - P, a += a >> 31 & P; }
void dec(int& a, int b) { a -= b, a += a >> 31 & P; }
int add(int a, int b) { return inc(a, b), a; }
int mul(int a, int b) { return 1ll * a * b % P; }
struct matrix {
  int a[N][N];
  matrix() { memset(a, 0, sizeof a); }
  int* operator[](int x) { return a[x]; }
} E, I;
matrix mul(matrix a, matrix b) {
  matrix c;
  for (int i = 1; i <= r; ++i)
    for (int j = i; j <= r; ++j)
      for (int k = j; k <= r; ++k) inc(c[i][k], mul(a[i][j], b[j][k]));
  return c;
}
matrix pow(matrix a, int k) {
  matrix b;
  for (int i = 1; i <= r; ++i) b[i][i] = 1;
  for (; k; k >>= 1, a = mul(a, a))
    if (k & 1) b = mul(b, a);
  return b;
}
int main() {
  int n, m, ans = 0, cnt;
  scanf("%s%d", str + 1, &m), m += n = strlen(str + 1), cnt = (n + 1) / 2,
                                   r = n + cnt * 2 - 1;
  for (int i = 1; i <= n; ++i)
    f[i][i][0] = 1, f[i][i + 1][0] = i < n && str[i] == str[i + 1];
  for (int i = n - 1; i; --i)
    for (int j = str[i] == str[i + 1] ? i + 2 : i + 1; j <= n; ++j)
      if (str[i] == str[j])
        for (int k = 0; k <= n; ++k) f[i][j][k] = f[i + 1][j - 1][k];
      else
        for (int k = 1; k <= n; ++k)
          f[i][j][k] = add(f[i][j - 1][k - 1], f[i + 1][j][k - 1]);
  for (int i = 1; i < n; ++i) E[i][i] = 24, E[i][i + 1] = 1;
  for (int i = n; i < n + cnt; ++i)
    E[i][i] = 25, E[i][i + cnt] = 1, E[i - 1][i] = 1;
  for (int i = n + cnt; i <= r; ++i) E[i][i] = 26;
  I = pow(E, (m - 1) / 2), E = mul(E, I);
  for (int i = 0, p, k; i < n; ++i) {
    p = (n - i - 1) / 2, k = E[n - i][n + cnt + p];
    if (m & 1 && ~(n - i) & 1) dec(k, I[n - i][n + p]);
    inc(ans, mul(k, f[1][n][i]));
  }
  printf("%d", ans);
}