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 mod = 10007;
int sz, f[205][205][205];
char s[205];
struct matrix {
  long long a[305][305];
  long long* operator[](int x) { return a[x]; }
  matrix() { memset(a, 0, sizeof(a)); }
  matrix operator*(const matrix& b) {
    matrix c;
    for (int i = 0; i <= sz; i++)
      for (int j = i; j <= sz; j++)
        for (int k = i; k <= j; k++)
          c.a[i][j] = c.a[i][j] + a[i][k] * b.a[k][j];
    for (int i = 0; i <= sz; i++)
      for (int j = 0; j <= sz; j++) c.a[i][j] %= mod;
    return c;
  }
};
matrix ksm(matrix x, int k) {
  matrix ret, tmp = x;
  for (int i = 0; i <= sz; i++) ret[i][i] = 1;
  while (k) {
    if (k & 1) ret = ret * tmp;
    tmp = tmp * tmp;
    k >>= 1;
  }
  return ret;
}
int calc(matrix st, matrix mul, int k) {
  mul = ksm(mul, k);
  st = st * mul;
  return st[0][sz];
}
int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1), m;
  scanf("%d", &m);
  f[1][n][0] = 1;
  for (int len = n; len >= 1; len--)
    for (int l = 1, r = len; r <= n; l++, r++)
      if (s[l] == s[r])
        for (int k = 0; k < n; k++)
          f[l + 1][r - 1][k] = (f[l + 1][r - 1][k] + f[l][r][k]) % mod;
      else
        for (int k = 0; k < n; k++) {
          f[l + 1][r][k + 1] = (f[l + 1][r][k + 1] + f[l][r][k]) % mod;
          f[l][r - 1][k + 1] = (f[l][r - 1][k + 1] + f[l][r][k]) % mod;
        }
  static matrix start, mul;
  sz = n + (n + 1) / 2 + 1;
  start[0][1] = 1;
  for (int i = 1; i <= n; i++)
    start[0][n + 1] =
        (start[0][n + 1] + f[i][i - 1][0] + f[i + 1][i - 1][0]) % mod;
  for (int i = 1; i <= n; i++) {
    mul[i][i] = 24;
    for (int j = 1; j <= n; j++)
      (mul[i][n + 1 + (i + (n & 1)) / 2] +=
       f[j][j - 1][i] + f[j + 1][j - 1][i]) %= mod;
    if (i != n) mul[i][i + 1] = 1;
  }
  for (int i = n + 1; i < sz; i++) mul[i][i] = 25, mul[i][i + 1] = 1;
  mul[sz][sz] = 26;
  int ans = calc(start, mul, (n + m + 1) / 2);
  if ((n + m) & 1) {
    for (int i = 1; i <= n; i++)
      start[0][n + 1] = (start[0][n + 1] - f[i + 1][i - 1][0]) % mod;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        (mul[i][n + 1 + (i + (n & 1)) / 2] -= f[j + 1][j - 1][i]) %= mod;
    mul[sz][sz] = 0;
    ans = (ans - calc(start, mul, (n + m + 1) / 2)) % mod;
  }
  cout << (ans + mod) % mod << "\n";
  return 0;
}