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, N, ans;
int a[405][405], b[405][405], f[205][205][205];
char p[205];
inline void pl(int &x, int y) { x = (x + y) % 10007; }
inline void cheng(int a[405][405], int b[405][405]) {
  int c[405][405] = {};
  for (int i = 1; i <= N; i++)
    for (int j = i; j <= N; j++)
      for (int k = j; k <= N; k++) pl(c[i][k], a[i][j] * b[j][k]);
  memcpy(a, c, sizeof(c));
}
int main() {
  scanf("%s%d", p + 1, &n);
  m = strlen(p + 1);
  int u, x;
  f[1][m][0] = 1;
  for (int i = m - 1; i >= 0; i--)
    for (int j = 1; j <= m - i; j++)
      for (int k = 0; k <= m; k++) {
        u = j + i;
        if ((x = f[j][u][k]) > 0) {
          if (p[j] == p[u])
            pl(f[j + 1][u - 1][k], x);
          else
            pl(f[j + 1][u][k + 1], x), pl(f[j][u - 1][k + 1], x);
        }
      }
  n += m;
  int flag = n & 1;
  n /= 2;
  int S = m, T = (m + 1) / 2;
  N = S + 2 * T + 1;
  for (int i = 1; i <= S + T - 1; i++) a[i][i + 1] = 1;
  for (int i = 0; i <= T; i++) a[S + i][N - i] = 1;
  for (int i = 1; i <= S; i++) a[i][i] = 24;
  for (int i = 1; i <= T; i++) a[S + i][S + i] = 25;
  for (int i = S + T + 1; i <= N; i++) a[i][i] = 26;
  for (int i = 1; i <= N; i++) b[i][i] = 1;
  for (int k = n; k; k /= 2) {
    if (k & 1) cheng(b, a);
    cheng(a, a);
  }
  for (int i = 0; i <= m; i++) {
    int v1 = i, v2 = (m - i + 1) / 2, s = 0;
    for (int j = 1; j <= m; j++)
      pl(s, f[j + 1][j - 1][i]), pl(s, f[j][j - 1][i]);
    if (flag)
      ans = (s * b[S - v1 + 1][N - v2] % 10007 * 26 + ans) % 10007;
    else
      ans = (s * b[S - v1 + 1][N - v2] % 10007 + ans) % 10007;
    if (flag && (m - v1) % 2 == 1) {
      s = 0;
      for (int j = 1; j <= m; j++) pl(s, f[j][j][i]);
      ans = (s * b[S - v1 + 1][S + v2] + ans) % 10007;
    }
  }
  printf("%d\n", ans);
  return 0;
}