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;
inline int inc(int &a, int b) {
  return a = (a + b < 10007 ? a + b : a + b - 10007);
}
inline int mul(int a, int b) { return a * b % 10007; }
char s[205];
int n, m, k, ans = 1, c1, c2;
int dp[205][205][205];
void getdp(void) {
  dp[0][n + 1][0] = 1;
  for (int i = 0; i <= n; i++)
    for (int j = n + 1; j > i + 1; j--)
      for (int p = 0; p <= n; p++)
        if (s[i + 1] == s[j - 1])
          inc(dp[i + 1][j - 1][p], dp[i][j][p]);
        else if (p < n) {
          inc(dp[i + 1][j][p + 1], dp[i][j][p]);
          inc(dp[i][j - 1][p + 1], dp[i][j][p]);
        }
  return;
}
struct matrix {
  int M[305][305];
};
matrix mul(matrix m1, matrix m2) {
  matrix temp;
  for (int i = 0; i < k; i++)
    for (int j = i; j < k; j++) {
      temp.M[i][j] = 0;
      for (int p = i; p <= j; p++)
        inc(temp.M[i][j], mul(m1.M[i][p], m2.M[p][j]));
    }
  return temp;
}
matrix pow(matrix base, int p) {
  matrix res;
  for (int i = 0; i < k; i++)
    for (int j = 0; j < k; j++) res.M[i][j] = (i == j);
  while (p > 0) {
    if (p & 1) res = mul(res, base);
    base = mul(base, base);
    p >>= 1;
  }
  return res;
}
int main(void) {
  scanf("%s%d", s + 1, &m);
  n = strlen(s + 1);
  getdp();
  matrix b1, b2;
  c1 = n;
  c2 = (n + 1) >> 1;
  k = c1 + c2 + 1;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= c1; j++) {
      inc(b1.M[j][k - (n + 1 - j) / 2], dp[i][i][j]);
      inc(b2.M[j][k - (n - j) / 2], dp[i][i + 1][j]);
    }
  for (int i = 1; i <= c1; i++) {
    b1.M[i - 1][i] = b2.M[i - 1][i] = 1;
    b1.M[i][i] = b2.M[i][i] = 24;
  }
  for (int i = c1 + 1; i <= c1 + c2; i++) {
    if (i < c1 + c2) b1.M[i][i + 1] = b2.M[i][i + 1] = 1;
    b1.M[i][i] = b2.M[i][i] = 25;
  }
  b1.M[0][0] = b2.M[0][0] = 26;
  matrix res1 = pow(b1, (n + m + 1) >> 1);
  matrix res2 = pow(b2, (n + m) >> 1);
  if ((n + m) & 1) res2.M[0][k - 1] = mul(res2.M[0][k - 1], 26);
  printf("%d\n", inc(res1.M[0][k - 1], res2.M[0][k - 1]));
  return 0;
}