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;
int n24, n25, n26, n, m, f[230][230][230], mod = 10007, N, ans;
struct tree {
  int e[610][610];
  tree() { memset(e, 0, sizeof(e)); }
  void newnode() {
    for (int i = 1; i <= N; i++) e[i][i] = 1;
  }
  inline tree operator*(const tree &b) const {
    tree c;
    for (int i = 1; i <= N; i++)
      for (int k = i; k <= N; k++) {
        if (!e[i][k]) continue;
        for (int j = k; j <= N; j++)
          c.e[i][j] = (c.e[i][j] + e[i][k] * b.e[k][j]) % mod;
      }
    return c;
  }
} a, b;
char s[230];
void add(int &x, int y) {
  x += y;
  if (x >= mod) x -= mod;
}
void dp();
void ksm(int);
int main() {
  scanf("%s", s + 1);
  scanf("%d", &m);
  n = strlen(s + 1);
  m += n;
  dp();
  n24 = n - 1;
  n25 = (n + 1) / 2;
  n26 = n25;
  N = n24 + n25 + n26;
  for (int i = 1; i <= n24; i++) a.e[i][i + 1] = 1, a.e[i][i] = 24;
  for (int i = 1; i <= n25; i++)
    a.e[i + n24][i + n24 + 1] = (i != n25), a.e[i + n24][i + n24] = 25;
  for (int i = 1; i <= n26; i++)
    a.e[i + n24][i + n24 + n25] = 1, a.e[i + n24 + n25][i + n24 + n25] = 26;
  ksm(m / 2);
  for (int i = 0; i <= n24; i++) {
    int x = n24 - i + 1, y = n24 + n25 + (n - i + 1) / 2;
    add(ans, f[1][n][i] * b.e[x][y] % mod);
  }
  if (m & 1) {
    ans = ans * 26 % mod;
    for (int i = 0; i <= n24; i++) {
      if ((n - i) & 1) {
        int x = n24 - i + 1, y = n24 + (n - i + 1) / 2;
        add(ans, f[1][n][i] * b.e[x][y] % mod);
      }
    }
  }
  printf("%d", ans);
  return 0;
}
void dp() {
  for (int i = 1; i <= n + 1; i++) f[i][i - 1][0] = 1;
  for (int i = 2; i <= n + 1; i++) f[i][i - 2][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j + i - 1 <= n; j++) {
      int le = j, ri = j + i - 1;
      if (s[le] == s[ri]) {
        for (int k = 0; k <= n; k++) add(f[le][ri][k], f[le + 1][ri - 1][k]);
      } else {
        for (int k = 0; k <= n; k++) {
          add(f[le][ri][k], f[le][ri - 1][k - 1]);
          add(f[le][ri][k], f[le + 1][ri][k - 1]);
        }
      }
    }
  }
}
void ksm(int x) {
  b.newnode();
  while (x) {
    if (x & 1) b = b * a;
    x >>= 1;
    a = a * a;
  }
}