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>
const int mod = 1e4 + 7;
char s[205];
int n, m, f[205][205][205], w[205], tl, r[205], g[205], fin;
struct Matrix {
  int r, c, A[305][305];
  void reset(int r1, int c1) {
    r = r1;
    c = c1;
    std::memset(A, 0, sizeof(A));
  }
};
Matrix mul(Matrix A, Matrix B) {
  Matrix C;
  C.reset(A.r, B.c);
  for (int i = 1; i <= A.r; ++i)
    for (int j = i; j <= A.c; ++j)
      for (int k = j; k <= B.c; ++k)
        C.A[i][k] = (C.A[i][k] + A.A[i][j] * B.A[j][k] % mod) % mod;
  return C;
}
Matrix expo(Matrix A, int b) {
  if (b == 1) return A;
  Matrix D = expo(A, b >> 1);
  D = mul(D, D);
  if (b & 1) D = mul(D, A);
  return D;
}
int main() {
  scanf("%s", s + 1);
  m = std::strlen(s + 1);
  scanf("%d", &n);
  n += m;
  f[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 - 1)
            f[i + 1][j - 1][k] = (f[i + 1][j - 1][k] + f[i][j][k]) % mod;
          else
            w[k] = (w[k] + f[i][j][k]) % mod;
        } else {
          f[i][j - 1][k + 1] = (f[i][j - 1][k + 1] + f[i][j][k]) % mod;
          f[i + 1][j][k + 1] = (f[i + 1][j][k + 1] + f[i][j][k]) % mod;
        }
      }
  for (int i = 1; i <= m; ++i) r[i] = ++tl;
  for (int i = (m + 1) / 2; i >= 1; --i) g[i] = ++tl;
  fin = ++tl;
  Matrix M, G;
  G.reset(tl, tl);
  M.reset(1, tl);
  for (int i = 1; i < m; ++i) G.A[r[i]][r[i + 1]] = 1;
  for (int i = 2; i <= (m + 1) / 2; ++i) G.A[g[i]][g[i - 1]] = 1;
  for (int i = 1; i <= m; ++i) G.A[r[i]][r[i]] = 24;
  for (int i = 1; i <= (m + 1) / 2; ++i) G.A[g[i]][g[i]] = 25;
  for (int i = 1; i <= m; ++i) G.A[r[i]][g[(m - i + 1) / 2]] = w[i];
  G.A[g[1]][fin] = 1;
  G.A[fin][fin] = 26;
  M.A[1][1] = 1;
  M.A[1][g[(m + 1) / 2]] = w[0];
  M = mul(M, expo(G, (n + 1) / 2));
  if (n % 2 == 0) {
    printf("%d ", M.A[1][tl]);
    return 0;
  }
  int ans1 = M.A[1][tl];
  G.reset(tl, tl);
  M.reset(1, tl);
  M.A[1][1] = 1;
  std::memset(w, 0, sizeof(w));
  for (int i = 1; i < m; ++i)
    for (int k = 0; k <= m; ++k)
      if (s[i] == s[i + 1]) w[k] = (w[k] + f[i][i + 1][k]) % mod;
  G.reset(tl, tl);
  M.reset(1, tl);
  for (int i = 1; i < m; ++i) G.A[r[i]][r[i + 1]] = 1;
  for (int i = 2; i <= (m + 1) / 2; ++i) G.A[g[i]][g[i - 1]] = 1;
  for (int i = 1; i <= m; ++i) G.A[r[i]][r[i]] = 24;
  for (int i = 1; i <= (m + 1) / 2; ++i) G.A[g[i]][g[i]] = 25;
  for (int i = 1; i <= m; ++i) G.A[r[i]][g[(m - i + 1) / 2]] = w[i];
  G.A[g[1]][fin] = 1;
  M.A[1][1] = 1;
  M.A[1][g[(m + 1) / 2]] = w[0];
  M = mul(M, expo(G, (n + 1) / 2));
  printf("%d", (ans1 - M.A[1][tl] + mod) % mod);
  return 0;
}