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 n, m, ans, f[205][205][205];
char s[205];
inline void upd(int &x, int y) { x = (x + y) % mod; }
struct mat {
  int s[620][620];
  mat() { memset(s, 0, sizeof s); }
  mat operator*(const mat &p) const {
    mat c;
    for (int k = 1; k < n * 3; ++k)
      for (int i = 1; i < n * 3; ++i)
        if (s[i][k])
          for (int j = 1; j < n * 3; ++j)
            if (p.s[k][j]) upd(c.s[i][j], s[i][k] * p.s[k][j]);
    return c;
  }
} g, h, hh;
inline mat pw(mat x, int k) {
  mat r;
  for (int i = 1; i < n * 3; ++i) r.s[i][i] = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * x;
    x = x * x;
  }
  return r;
}
int main() {
  scanf("%s%d", s + 1, &m);
  n = strlen(s + 1);
  m += n;
  for (int i = 1; i <= n; ++i) f[i][i][0] = 1;
  for (int i = 1; i < n; ++i)
    if (s[i] == s[i + 1]) f[i][i + 1][0] = 1;
  for (int i = 0; i < n; ++i)
    for (int j = 1; j + i <= n; ++j)
      for (int k = 0, t; k <= n; ++k)
        if (t = f[j][j + i][k]) {
          if (j + i + 1 <= n && s[j] != s[j + i + 1])
            upd(f[j][j + i + 1][k + 1], t);
          if (j - 1 && s[j - 1] != s[j + i]) upd(f[j - 1][j + i][k + 1], t);
          if (j - 1 && j + i + 1 <= n && s[j - 1] == s[j + i + 1])
            upd(f[j - 1][j + i + 1][k], t);
        }
  for (int i = 1; i < n; ++i) {
    g.s[i][i] = 24;
    g.s[i][i + 1] = 1;
  }
  for (int i = n; i < n * 2; ++i) {
    g.s[i][i] = 25;
    if (i + 1 < n * 2) g.s[i][i + 1] = 1;
    g.s[i][i + n] = 1;
  }
  for (int i = n * 2; i < n * 3; ++i) g.s[i][i] = 26;
  h = pw(g, (m + 1) / 2 - 1);
  g = g * h;
  for (int i = 0; i <= n; ++i) {
    int j = (n - i + 1) / 2 - 1;
    upd(ans, f[1][n][i] * g.s[n - i][n * 2 + j]);
    if ((m & 1) && !((n - i) & 1))
      upd(ans, (-f[1][n][i] * h.s[n - i][n + j]) % mod + mod);
  }
  printf("%d\n", ans);
  return 0;
}