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, P, S, T;
int st, ed;
char ss[205];
int dp[205][205][205], ans;
int f[205 * 2][205 * 2], g[205 * 2][205 * 2], tp[205 * 2][205 * 2];
int sum[205];
void Calc(int x) {
  int tmp, i, j, t, s;
  while (x) {
    if (x & 1) {
      for (i = 1; i <= P; i++)
        for (j = i; j <= P; j++) {
          for (tp[i][j] = 0, t = i; t <= j; t++) {
            tp[i][j] += g[i][t] * f[t][j];
            if (tp[i][j] >= 1900000000) tp[i][j] %= 10007;
          }
          tp[i][j] %= 10007;
        }
      memcpy(g, tp, sizeof(g));
    }
    x >>= 1;
    for (i = 1; i <= P; i++)
      for (j = i; j <= P; j++) {
        for (tp[i][j] = 0, t = i; t <= j; t++) {
          tp[i][j] += f[i][t] * f[t][j];
          if (tp[i][j] >= 1900000000) tp[i][j] %= 10007;
        }
        tp[i][j] %= 10007;
      }
    memcpy(f, tp, sizeof(f));
  }
}
int main() {
  int i, j, t;
  scanf("%s", ss + 1);
  S = strlen(ss + 1);
  scanf("%d", &N);
  M = N + S;
  dp[1][S][0] = 1;
  for (i = 1; i <= S; i++)
    for (j = S; j >= i; j--)
      for (t = 0; t <= S; t++)
        if (dp[i][j][t]) {
          if (ss[i] != ss[j]) {
            dp[i + 1][j][t + 1] = (dp[i + 1][j][t + 1] + dp[i][j][t]) % 10007;
            dp[i][j - 1][t + 1] = (dp[i][j - 1][t + 1] + dp[i][j][t]) % 10007;
          } else
            dp[i + 1][j - 1][t] = (dp[i + 1][j - 1][t] + dp[i][j][t]) % 10007;
        }
  for (i = 1; i <= S + 1; i++)
    for (j = i - 1; j >= 0; j--)
      for (t = 0; t < S; t++) sum[t] = (sum[t] + dp[i][j][t]) % 10007;
  T = (S + 1) / 2, P = S + T + T;
  for (i = 1; i <= S; i++) f[i][i] = 24;
  for (i = S + 1; i <= S + T; i++) f[i][i] = 25, f[i][i + T] = 1;
  for (i = S + T + 1; i <= P; i++) f[i][i] = 26;
  for (i = 1; i < S + T; i++) f[i][i + 1] = 1;
  for (i = 1; i <= P; i++) g[i][i] = 1;
  Calc((M + 1) / 2);
  for (i = 0; i < S; i++) {
    st = S - i + 1, ed = S + T + st / 2;
    ans = (ans + sum[i] * g[st][ed]) % 10007;
  }
  if (M & 1) {
    memset(f, 0, sizeof(f));
    for (i = 1; i <= S; i++) f[i][i] = 24;
    for (i = S + 1; i <= S + T; i++) f[i][i] = 25, f[i][i + T] = 1;
    for (i = S + T + 1; i <= P; i++) f[i][i] = 26;
    for (i = 1; i < S + T; i++) f[i][i + 1] = 1;
    memset(g, 0, sizeof(g));
    for (i = 1; i <= P; i++) g[i][i] = 1;
    Calc((M + 1) / 2 - 1);
    for (i = 0; i < S; i++)
      if ((S - i) % 2 == 0) {
        st = S - i + 1, ed = S + st / 2;
        ans = (ans - sum[i] * g[st][ed] % 10007 + 10007) % 10007;
      }
  }
  printf("%d\n", ans);
  return 0;
}