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;
const int MaxN = 410;
const int MOD = 10007;
char s[MaxN];
int n, m, N, cnt, a[MaxN][MaxN], b[MaxN][MaxN], c[MaxN][MaxN];
int f[MaxN][MaxN][MaxN];
inline void mul(int a[][MaxN], int b[][MaxN], int c[][MaxN]) {
  static int d[MaxN][MaxN];
  memset(d, 0, sizeof(d));
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      for (int k = i; k <= j; k++)
        d[i][j] = (d[i][j] + a[i][k] * b[k][j]) % MOD;
  memcpy(c, d, sizeof(d));
}
inline void pow(int x) {
  memset(c, 0, sizeof(c));
  for (int i = 0; i < N; i++) c[i][i] = 1;
  for (; x; x >>= 1, mul(a, a, a))
    if (x & 1) mul(c, a, c);
}
int F(int l, int r, int C) {
  if (f[l][r][C] != -1) return f[l][r][C];
  int &t = f[l][r][C];
  if (l == r)
    return t = !C;
  else if (s[l] == s[r])
    return t = (l + 1 == r ? !C : F(l + 1, r - 1, C));
  else
    return t = C ? F(l, r - 1, C - 1) + F(l + 1, r, C - 1) % MOD : 0;
}
int main() {
  scanf("%s%d", s, &n);
  m = strlen(s);
  n += m;
  cnt = n + 1 >> 1;
  int n1 = m - 1, n2 = m + 1 >> 1, n3 = n2;
  N = n1 + n2 + n3;
  for (int i = 0; i < n1; i++) a[i][i] = 24, a[i][i + 1] = 1;
  for (int i = n1; i < n1 + n2; i++)
    a[i][i] = 25, a[i][i + n2] = 1, i < n1 + n2 - 1 ? a[i][i + 1] = 1 : 0;
  for (int i = n1 + n2; i < N; i++) a[i][i] = 26;
  memcpy(b, a, sizeof(a));
  pow(cnt - 1);
  mul(c, b, a);
  memset(f, 0xff, sizeof(f));
  long long res = 0;
  for (int c1 = 0; c1 < m; c1++) {
    int c2 = m - c1 + 1 >> 1, flag = ~(m - c1) & 1;
    int c3 = cnt - c1 - c2;
    if (c3 < 0) continue;
    int tot = F(0, m - 1, c1);
    res += 1LL * tot * a[n1 - c1][n1 + n2 + c2 - 1];
    if ((n & 1) && flag)
      res += 1LL * MOD * MOD - 1LL * tot * c[n1 - c1][n1 + c2 - 1];
  }
  printf("%d\n", int(res % MOD));
  return 0;
}