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 md = 1e4 + 7, N = 320;
int f[205][205][205], n, m, g[205], M;
char s[N];
inline void upd(int& a) { a += a >> 31 & md; }
struct mat {
  int a[N][N];
  inline mat() { memset(a, 0, sizeof a); }
  inline void operator*=(const mat& b) {
    static int c[N][N];
    for (int i = 0; i <= M; ++i)
      for (int j = 0; j <= M; ++j) c[i][j] = 0;
    for (int i = 0; i <= M; ++i)
      for (int j = i; j <= M; ++j)
        for (int k = i; k <= j; ++k)
          c[i][j] = (c[i][j] + a[i][k] * b.a[k][j]) % md;
    for (int i = 0; i <= M; ++i)
      for (int j = 0; j <= M; ++j) a[i][j] = c[i][j];
  }
} A, B;
void build() {
  A = mat(), B = mat();
  A.a[0][1] = 1, B.a[M][M] = 26;
  A.a[0][M - (n + 1 >> 1)] = g[0];
  for (int i = 1; i <= n; ++i) {
    B.a[i][i] = 24, B.a[i][M - (n - i + 1 >> 1)] = g[i];
    B.a[i][i + 1] = 1;
  }
  B.a[n][n + 1] = 0;
  for (int i = n + 1; i < M; ++i) B.a[i][i + 1] = 1, B.a[i][i] = 25;
}
mat pow(mat a, int b, mat res) {
  for (; b; b >>= 1, a *= a)
    if (b & 1) res *= a;
  return res;
}
int main() {
  scanf("%s%d", s + 1, &m), 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)
          upd((i + 1 < j ? f[i + 1][j - 1][k] : g[k]) += f[i][j][k] - md);
      } else
        for (int k = 1; k <= i + n - j; ++k) {
          upd(f[i + 1][j][k] += f[i][j][k - 1] - md),
              upd(f[i][j - 1][k] += f[i][j][k - 1] - md);
        }
  M = n + (n + 1 >> 1) + 1;
  build();
  if ((n + m) % 2 == 0)
    printf("%d\n", pow(B, n + m >> 1, A).a[0][M]);
  else {
    int ans = pow(B, n + m + 1 >> 1, A).a[0][M];
    memset(g, 0, sizeof g);
    for (int i = 1; i < n; ++i)
      if (s[i] == s[i + 1])
        for (int j = 0; j <= n; ++j) upd(g[j] += f[i][i + 1][j] - md);
    build();
    B.a[M][M] = 0;
    upd(ans -= pow(B, n + m + 1 >> 1, A).a[0][M]);
    printf("%d\n", ans);
  }
  return 0;
}