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 inf = 2147483647;
const int mod = 1e4 + 7;
int _max(int x, int y) { return x > y ? x : y; }
int _min(int x, int y) { return x < y ? x : y; }
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
  return x * f;
}
void put(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) put(x / 10);
  putchar(x % 10 + '0');
}
int add(int x, int y) {
  x += y;
  return x >= mod ? x - mod : x;
}
int dec(int x, int y) {
  x -= y;
  return x < 0 ? x + mod : x;
}
int pow_mod(int a, int k) {
  int ans = 1;
  for (; k; k /= 2, a = a * a % mod)
    if (k & 1) ans = ans * a % mod;
  return ans;
}
int hh = 1, s1[201][201], s2[201][201], h1[201][201], h2[201][201];
int g[201][201][201];
char ss[201];
void C(int n, int m) {
  hh = (n - m) % mod * hh % mod * pow_mod(m + 1, mod - 2) % mod;
}
int main() {
  scanf("%s", ss + 1);
  int n = read(), len = strlen(ss + 1);
  n += len;
  int u;
  if (n & 1) {
    u = n / 2;
    hh = 1;
    for (int i = 0; i < len; i++)
      s2[i + 1][0] = hh * pow_mod(25, u - i) % mod,
             s2[0][i + 1] = hh * pow_mod(24, u - i) % mod, C(u, i);
    for (int i = 0; i < len; i++)
      for (int j = 0; j < len; j++)
        s2[i + 1][j + 1] = dec(s2[i + 1][j], s2[i][j + 1]);
  }
  u = (n + 1) / 2;
  hh = 1;
  for (int i = 0; i < len; i++)
    s1[i + 1][0] = hh * pow_mod(25, u - i) % mod,
           s1[0][i + 1] = hh * pow_mod(24, u - i) % mod, C(u, i);
  for (int i = 0; i < len; i++)
    for (int j = 0; j < len; j++)
      s1[i + 1][j + 1] = dec(s1[i + 1][j], s1[i][j + 1]);
  g[1][len][0] = 1;
  for (int q = len; q >= 1; q--)
    for (int l = 1; l <= len - q + 1; l++)
      for (int k = 0; k < len; k++) {
        int r = l + q - 1;
        if (!g[l][r][k]) continue;
        int c = g[l][r][k];
        int o = len - q - 2 * k;
        if (o < 0) {
          o--, o++;
        }
        if (ss[l] == ss[r]) {
          if (l < r) g[l + 1][r - 1][k + 1] = add(g[l + 1][r - 1][k + 1], c);
          h1[k + 1][o] = add(h1[k + 1][o], c);
          if (l + 1 == r) h2[k + 1][o] = add(h2[k + 1][o], c);
        } else {
          g[l + 1][r][k] = add(g[l + 1][r][k], c);
          g[l][r - 1][k] = add(g[l][r - 1][k], c);
          h1[k][o + 1] = add(h1[k][o + 1], c);
        }
      }
  int ans = pow_mod(26, u);
  for (int i = 0; i <= len; i++)
    for (int j = 0; j <= len; j++) ans = dec(ans, h1[i][j] * s1[i][j] % mod);
  if (n & 1) {
    for (int i = 0; i <= len; i++)
      for (int j = 0; j <= len; j++)
        if (h2[i][j]) ans = dec(ans, h2[i][j] * s2[i][j] % mod);
  }
  put(ans), puts("");
  return 0;
}