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>
inline int mod(int x) { return x >= 10007 ? x - 10007 : x; }
inline int calc(int x, int y) {
  int z = 1;
  for (; y; x = x * x % 10007, y >>= 1)
    if (y & 1) z = x * z % 10007;
  return z;
}
int X, a[405][405], b[405][405], c[405][405], d[202], e[202], f[3][202][202], m,
    n, o, x, y, z;
char s[202];
inline void mul_a() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= i; j++)
      for (int k = j; k <= i; k++)
        c[i][j] = (c[i][j] + a[i][k] * a[k][j]) % 10007;
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= i; j++) a[i][j] = c[i][j], c[i][j] = 0;
}
inline void mul_b() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= i; j++)
      for (int k = j; k <= i; k++)
        c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % 10007;
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= i; j++) b[i][j] = c[i][j], c[i][j] = 0;
}
inline void solve(int s, int q) {
  n = m + (m >> 1) + 1 + (m >> 1) + 2;
  for (int i = 0; i < m; i++) a[i][i] = 24, a[i + 1][i] = 1;
  for (int i = 0; i << 1 <= m; i++)
    a[m + i][m + i] = 25, a[m + i + 1][m + i] = 1;
  for (int i = 0; i < (m >> 1) + 2; i++)
    a[m + (m >> 1) + 1 + i][m + (m >> 1) + 1 + i] = s, a[m + (m >> 1) + 1 + i]
                                                        [m + i - 1]++;
  for (int i = a[m + (m >> 1) + 1][m + (m >> 1)] = 0; i < n; i++) b[i][i] = 1;
  for (; q; mul_a(), q >>= 1)
    if (q & 1) mul_b();
}
int q;
int main() {
  scanf("%s%d", s + 1, &q), q += m = strlen(s + 1), o = q & 1, q >>= 1, z = 2,
                                 f[x][y = 1][0] = 1;
  if (o == m)
    return 0 * printf("%d\n", mod(10007 + calc(26, q + 1) - calc(25, q + 1)));
  for (int j = m; j-- > 1; x ^= y ^= x ^= y, y ^= z ^= y ^= z)
    for (int i = 1; i + j <= m; i++)
      if (s[i] == s[i + j])
        for (int k = 0; k < m; f[x][i][k++] = 0)
          f[z][i + 1][k + 1] = mod(f[z][i + 1][k + 1] + f[x][i][k]);
      else
        for (int k = 0; k < m; f[x][i][k++] = 0)
          f[y][i][k] = mod(f[y][i][k] + f[x][i][k]),
          f[y][i + 1][k] = mod(f[y][i + 1][k] + f[x][i][k]);
  if (o) {
    for (int i = 1; i <= m + 1; i++)
      for (int k = 0; k << 1 <= m; k++) d[k] = mod(d[k] + f[x][i][k]);
    solve(25, q);
    for (int i = 0; i << 1 <= m; i++)
      X = (X + d[i] * b[m + (m >> 1) + 1 + i][i << 1 | 1]) % 10007;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) a[i][j] = b[i][j] = 0;
    for (int i = 1; i << 1 <= m; i++) d[i] = 0;
  }
  for (int i = 1; i <= m; i++)
    for (int k = 0; k < m; f[x][i][k++] = 0)
      f[z][i + 1][k + 1] = mod(f[z][i + 1][k + 1] + f[x][i][k]);
  for (int i = 1; i <= m + 1; i++)
    for (int k = 0; k << 1 <= m; k++) d[k] = mod(d[k] + f[y][i][k]);
  for (int i = 1; i <= m + 1; i++)
    for (int k = 0; k << 1 <= m + 1; k++) e[k] = mod(e[k] + f[z][i][k]);
  solve(26, q), q = o ? 26 : 1;
  for (int i = 1; i << 1 <= m; i++)
    X = (X + (long long)q * d[i] * b[m + (m >> 1) + 1 + i][i << 1]) % 10007;
  for (int i = 1; i << 1 <= m + 1; i++)
    X = (X + (long long)q * e[i] * b[m + (m >> 1) + 1 + i][i - 1 << 1 | 1]) %
        10007;
  return 0 * printf("%d\n", X);
}