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 = 1e4 + 7;
int add(int a, int b) { return a + b >= Mod ? a + b - Mod : a + b; }
int dec(int a, int b) { return a - b < 0 ? a - b + Mod : a - b; }
int mul(int a, int b) { return a * b % Mod; }
void Add(int &a, int b) { a = add(a, b); }
void Mul(int &a, int b) { a = mul(a, b); }
void Dec(int &a, int b) { a = dec(a, b); }
const int N = 305;
int n, K, m;
char S[N];
int f[N][N][N], g[N], h[N];
struct mat {
  int a[N][N];
  void output() {
    for (int i = 0; i <= m; i++, puts(""))
      for (int j = 0; j <= m; j++) cout << a[i][j] << " ";
  }
  mat() { memset(a, 0, sizeof(a)); }
  void clr() { memset(a, 0, sizeof(a)); }
  void I() {
    for (int i = 0; i <= m; i++) a[i][i] = 1;
  }
  mat operator*(const mat &A) {
    mat B;
    for (int i = 0; i <= m; i++)
      for (int j = i; j <= m; j++)
        for (int k = i; k <= j; k++) Add(B.a[i][j], mul(a[i][k], A.a[k][j]));
    return B;
  }
};
mat ksm(mat a, int b) {
  mat as;
  as.I();
  for (; b; b >>= 1, a = a * a)
    if (b & 1) as = as * a;
  return as;
}
int main() {
  scanf("%s%d", S + 1, &K);
  n = strlen(S + 1);
  f[1][n][0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = n; j >= i; j--) {
      if (S[i] == S[j]) {
        for (int k = 0; k <= i + n - j; k++)
          if (i + 1 < j)
            Add(f[i + 1][j - 1][k], f[i][j][k]);
          else {
            Add(g[k], f[i][j][k]);
          }
      } else {
        for (int k = 0; k <= i + n - j; k++) {
          Add(f[i + 1][j][k + 1], f[i][j][k]);
          Add(f[i][j - 1][k + 1], f[i][j][k]);
        }
      }
    }
  m = n + (n + 1) / 2 + 1;
  mat A, B;
  B.a[m][m] = 26;
  for (int i = 1; i <= n; i++) {
    B.a[i][i] = 24;
    B.a[i][m - (n - i + 1) / 2] = g[i];
    if (i < n) B.a[i][i + 1] = 1;
  }
  for (int i = n + 1; i < m; i++) B.a[i][i + 1] = 1, B.a[i][i] = 25;
  A.a[0][1] = 1;
  A.a[0][n + 1] = g[0];
  if ((n + K) & 1 ^ 1) {
    A = A * ksm(B, (n + K) >> 1), cout << A.a[0][m];
    return 0;
  }
  A = A * ksm(B, (n + K + 1) >> 1);
  int as = A.a[0][m];
  A.clr();
  B.clr();
  memset(g, 0, sizeof(g));
  for (int i = 1; i <= n; i++)
    if (S[i] == S[i + 1])
      for (int k = 0; k <= n; k++) Add(g[k], f[i][i + 1][k]);
  A.a[0][1] = 1;
  A.a[0][n + 1] = g[0];
  for (int i = 1; i <= n; i++) {
    B.a[i][i] = 24;
    B.a[i][m - (n - i + 1) / 2] = g[i];
    if (i < n) B.a[i][i + 1] = 1;
  }
  for (int i = n + 1; i < m; i++) B.a[i][i + 1] = 1, B.a[i][i] = 25;
  A = A * ksm(B, (n + K + 1) >> 1);
  cout << dec(as, A.a[0][m]);
  return 0;
}