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>
#pragma GCC optimize("O3")
using namespace std;
const int N = 205, P = 10007;
char s[N];
int n, m, f[N][N][N], len, g[N], ans;
struct matrix {
  int f[N * 2][N * 2];
  matrix() { memset(f, 0, sizeof(f)); }
  inline matrix operator*(const matrix &b) const {
    matrix c;
    for (int i = 1; i <= m; i++)
      for (int k = 1; k <= m; k++) {
        if (!f[i][k]) continue;
        for (int j = 1; j <= m; j++)
          c.f[i][j] = (c.f[i][j] + f[i][k] * b.f[k][j]) % P;
      }
    return c;
  }
};
inline matrix ksm(matrix a, int b) {
  matrix res;
  for (int i = 1; i <= m; i++) res.f[i][i] = 1;
  while (b) {
    if (b & 1) res = res * a;
    a = a * a, b >>= 1;
  }
  return res;
}
int main() {
  scanf("%s%d", s + 1, &n);
  len = strlen(s + 1);
  f[1][len][0] = 1;
  for (int l = len; l; l--)
    for (int i = 1; i <= len - l + 1; i++) {
      int j = i + l - 1;
      for (int k = 0; k <= len; k++) {
        if (!f[i][j][k]) continue;
        if (len == 1) {
          g[k] = (g[k] + f[i][j][k]) % P;
          continue;
        }
        if (s[i] == s[j]) {
          f[i + 1][j - 1][k] = (f[i + 1][j - 1][k] + f[i][j][k]) % P;
          if (i + 1 > j - 1) g[k] = (g[k] + f[i][j][k]) % P;
        } else
          f[i + 1][j][k + 1] = (f[i + 1][j][k + 1] + f[i][j][k]) % P,
                          f[i][j - 1][k + 1] =
                              (f[i][j - 1][k + 1] + f[i][j][k]) % P;
      }
    }
  matrix c;
  for (int i = 1; i < len; i++) c.f[i][i + 1] = 1;
  for (int i = 1; i <= len; i++) c.f[i][i] = 24;
  c.f[len][len + 1] = 1;
  int num = (len + 1) / 2;
  for (int i = 1; i < num; i++) c.f[i + len][i + len + 1] = 1;
  for (int i = 1; i <= num; i++) c.f[i + len][i + len] = 25;
  m = num * 2 + len;
  for (int i = 1; i <= num; i++) c.f[i + len][i + len + num] = 1;
  for (int i = 1; i <= num; i++) c.f[i + len + num][i + len + num] = 26;
  c = ksm(c, (len + n) / 2);
  for (int i = 0; i <= len; i++) {
    int to = (len + 1 - i) / 2;
    ans = (ans + c.f[len - i + 1][len + to + num] * g[i]) % P;
  }
  if ((len + n) & 1) {
    ans = ans * 26 % P;
    for (int i = 0; i <= len; i++)
      if ((len - i) & 1)
        ans = (ans + c.f[len + 1 - i][len + (len + 1 - i) / 2] * g[i]) % P;
  }
  printf("%d\n", ans);
}