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 MAXN = 405, P = 10007;
int m, w1, w2, w3, ans, f[205][205][205];
long long n;
char s[MAXN];
struct Matrix {
  int a[MAXN][MAXN];
  inline int& operator()(int r, int c) { return a[r][c]; }
} I, Tr;
inline Matrix operator*(Matrix& A, Matrix& B) {
  static Matrix C;
  for (int i = 1; i <= m; ++i)
    for (int j = i; j <= m; ++j) {
      C(i, j) = 0;
      for (int k = i; k <= j; ++k) C(i, j) = (C(i, j) + A(i, k) * B(k, j)) % P;
    }
  return C;
}
int main() {
  scanf("%s%lld", s + 1, &n);
  m = strlen(s + 1);
  f[1][m][0] = 1;
  for (int len = m; len; --len)
    for (int l = 1, r = len; r <= m; ++l, ++r)
      for (int k = 0; k < m; ++k)
        if (f[l][r][k])
          if (s[l] == s[r])
            (f[l + 1][r - 1][k] += f[l][r][k]) %= P;
          else {
            (f[l + 1][r][k + 1] += f[l][r][k]) %= P;
            (f[l][r - 1][k + 1] += f[l][r][k]) %= P;
          }
  w1 = m;
  w2 = m + 1 >> 1;
  w3 = (m + 1 >> 1) + 1;
  m = w1 + w2 + w3;
  for (int i = 1; i < w1 + w2; ++i) Tr(i, i + 1) = 1;
  for (int i = 1; i <= w1; ++i) Tr(i, i) = 24;
  for (int i = 1; i <= w2; ++i) Tr(w1 + i, w1 + i) = 25;
  for (int i = 1; i <= w3; ++i) Tr(w1 + w2 + i, w1 + w2 + i) = 26;
  for (int i = 0; i <= w2; ++i) Tr(w1 + i, m - i) = 1;
  for (int i = 1; i <= m; ++i) I(i, i) = 1;
  for (long long k = (n + w1) / 2; k; k >>= 1, Tr = Tr * Tr)
    if (k & 1) I = I * Tr;
  for (int i = 0; i <= w1; ++i) {
    int j = w1 - i + 1 >> 1, sum = 0;
    for (int k = 1; k <= w1; ++k)
      sum = (sum + f[k + 1][k - 1][i] + f[k][k - 1][i]) % P;
    ans = (ans + I(w1 - i + 1, m - j) * sum % P * ((n + w1 & 1) ? 26 : 1)) % P;
    if (!(n + w1 & 1) || !(w1 - i & 1)) continue;
    sum = 0;
    for (int k = 1; k <= w1; ++k) (sum += f[k + 1][k - 1][i]) %= P;
    ans = (ans + I(w1 - i + 1, w1 + j) * sum) % P;
  }
  printf("%d\n", ans);
  return 0;
}