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;
const int P = 10007;
int n, m, A, B, siz, SS;
char s[N];
void Ad(int &x, int y) { x = (x + y) % P; }
struct Mat {
  int a[305][305];
  Mat() { memset(a, 0, sizeof(a)); }
} U, X;
long long a[305][305];
void Mul(Mat &A, Mat &B) {
  memset(a, 0, sizeof(a));
  for (int i = 0; i <= siz; ++i)
    for (int k = i; k <= siz; ++k)
      for (int j = k; j <= siz; ++j) a[i][j] += A.a[i][k] * B.a[k][j];
  for (int i = 0; i <= siz; ++i)
    for (int j = 0; j <= siz; ++j) A.a[i][j] = a[i][j] % P;
}
void prs() {
  for (int i = 0; i <= N - 1; ++i)
    for (int j = 0; j <= N - 1; ++j)
      if (U.a[i][j]) printf("(%d,%d):%d\n", i, j, U.a[i][j]);
}
int h[N][N][N], g[N];
void Pre() {
  h[1][m][0] = 1;
  for (int i = 1; i <= m; ++i)
    for (int j = m; j >= i; --j)
      for (int k = 0; k <= m; ++k) {
        if (s[i] == s[j])
          if (i + 1 >= j)
            Ad(g[k], h[i][j][k]);
          else
            Ad(h[i + 1][j - 1][k], h[i][j][k]);
        else {
          Ad(h[i + 1][j][k + 1], h[i][j][k]);
          Ad(h[i][j - 1][k + 1], h[i][j][k]);
        }
      }
}
void Mk1() {
  A = m - 1;
  B = (m + 1) / 2;
  siz = A + B + 1;
  SS = 0;
  for (int i = 1; i <= A; ++i)
    U.a[i][i] = 24, U.a[i][A + B + 1 - (m - i + 1) / 2] = g[i];
  U.a[0][0] = 24;
  for (int i = 0; i <= A - 1; ++i) U.a[i][i + 1] = 1;
  for (int i = 1; i <= B; ++i) U.a[A + i][A + i] = 25;
  for (int i = 1; i <= B; ++i) U.a[A + i][A + i + 1] = 1;
  U.a[A + B + 1][A + B + 1] = 26;
}
void Mk2() {
  memset(&U, 0, sizeof(U));
  memset(g, 0, sizeof(g));
  for (int i = 1; i <= m - 1; ++i)
    for (int k = 0; k <= m; ++k)
      if (s[i] == s[i + 1]) Ad(g[k], h[i][i + 1][k]);
  A = m - 1;
  B = (m + 1) / 2;
  for (int i = 1; i <= A; ++i)
    U.a[i][i] = 24, U.a[i][A + B + 1 - (m - i + 1) / 2] = g[i];
  U.a[0][0] = 24;
  for (int i = 0; i <= A - 1; ++i) U.a[i][i + 1] = 1;
  for (int i = 1; i <= B; ++i) U.a[A + i][A + i] = 25;
  for (int i = 1; i <= B; ++i) U.a[A + i][A + i + 1] = 1;
}
Mat Pow(Mat X, long long bs) {
  Mat an;
  an.a[SS][1] = 1;
  an.a[SS][A + 1] = g[0];
  for (; bs; bs >>= 1, Mul(X, X))
    if (bs & 1) Mul(an, X);
  return an;
}
int main() {
  cin >> (s + 1);
  m = strlen(s + 1);
  cin >> n;
  Pre();
  Mk1();
  Mat M = Pow(U, (n + m + 1) / 2);
  int ans = M.a[SS][A + B + 1];
  if ((n + m) & 1) {
    Mk2();
    M = Pow(U, (n + m + 1) / 2);
    Ad(ans, P - M.a[SS][A + B + 1]);
  }
  cout << ans << '\n';
  return 0;
}