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 N = 205, Mo = 10007;
void inc(int &x, int y) { x = x + y >= Mo ? x + y - Mo : x + y; }
int n, m, t, f[N][N][N], g[N];
char st[N];
struct Matrix {
  int a[305][305];
  friend Matrix operator*(Matrix a, Matrix b) {
    Matrix c;
    memset(c.a, 0, sizeof(c.a));
    for (int k = 1; k <= t; k++)
      for (int i = 1; i <= t; i++)
        for (int j = 1; j <= t; j++) c.a[i][j] += a.a[i][k] * b.a[k][j] % Mo;
    for (int i = 1; i <= t; i++)
      for (int j = 1; j <= t; j++) c.a[i][j] %= Mo;
    return c;
  }
} trs;
Matrix pwr(Matrix a, int y) {
  Matrix b;
  memset(b.a, 0, sizeof(b.a));
  for (int i = 1; i <= t; i++) b.a[i][i] = 1;
  for (; y; y >>= 1, a = a * a)
    if (y & 1) b = b * a;
  return b;
}
int main() {
  scanf("%s", st + 1);
  n = strlen(st + 1);
  scanf("%d", &m);
  f[1][n][0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = n; j >= i; j--)
      if (st[i] == st[j]) {
        for (int k = 0; k <= i + n - j - 1; k++) {
          if (i + 1 <= j - 1)
            inc(f[i + 1][j - 1][k], f[i][j][k]);
          else
            inc(g[k], f[i][j][k]);
        }
      } else {
        for (int k = 0; k <= i + n - j - 1; k++) {
          inc(f[i + 1][j][k + 1], f[i][j][k]);
          inc(f[i][j - 1][k + 1], f[i][j][k]);
        }
      }
  t = n + (n + 1) / 2 + 1;
  trs.a[t][t] = 26;
  for (int i = 1; i <= n; i++) {
    trs.a[i][i] = 24;
    trs.a[i][t - (n - i + 1) / 2] = g[i];
    if (i < n) trs.a[i][i + 1] = 1;
  }
  for (int i = n + 1; i <= t - 1; i++) trs.a[i][i + 1] = 1, trs.a[i][i] = 25;
  trs = pwr(trs, (n + m + 1) >> 1);
  int ans = (trs.a[1][t] + trs.a[n + 1][t] * g[0]) % Mo;
  if ((n + m) & 1) {
    for (int i = 1; i <= t; i++)
      for (int j = 1; j <= t; j++) trs.a[i][j] = 0;
    for (int i = 0; i <= n; i++) g[i] = 0;
    for (int i = 1; i <= n; i++)
      if (st[i] == st[i + 1])
        for (int k = 0; k <= n; k++) inc(g[k], f[i][i + 1][k]);
    for (int i = 1; i <= n; i++) {
      trs.a[i][i] = 24;
      trs.a[i][t - (n - i + 1) / 2] = g[i];
      if (i < n) trs.a[i][i + 1] = 1;
    }
    for (int i = n + 1; i <= t - 1; i++) trs.a[i][i + 1] = 1, trs.a[i][i] = 25;
    trs = pwr(trs, (n + m + 1) >> 1);
    ans = (ans - trs.a[1][t] - trs.a[n + 1][t] * g[0]) % Mo;
  }
  printf("%d\n", (ans + Mo) % Mo);
  return 0;
}