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 = 205;
const int N = 301;
const int mod = 1e4 + 7;
int n, m, K, mr;
char s[maxN];
int h[maxN][maxN][maxN];
struct Matrix {
  int a[N][N];
  Matrix(int op = -1) {
    memset(a, 0, sizeof(a));
    if (~op)
      for (int i = 0; i <= m; ++i) a[i][i] = 1;
  }
  int* operator[](int x) { return a[x]; }
  const int* operator[](int x) const { return a[x]; }
} coe;
inline Matrix operator*(const Matrix& x, const Matrix& y) {
  Matrix res;
  for (int i = 0; i <= m; ++i)
    for (int j = i; j <= m; ++j)
      if (x[i][j])
        for (int k = j; k <= m; ++k)
          if (y[j][k]) (res[i][k] += x[i][j] * y[j][k]) %= mod;
  return res;
}
int H(int i, int l, int r) {
  if (i < 0) return 0;
  if (~h[i][l][r]) return h[i][l][r];
  int res = 0;
  if (l == 0) {
    for (int u = 1; u <= n; ++u)
      for (int v = 0; v <= 1; ++v)
        if (u + v <= n and s[u] == s[u + v]) res += H(i, u, u + v);
    return h[i][l][r] = res % mod;
  }
  int I = i - (s[l] != s[r]);
  if (l > 1 and s[l - 1] == s[r + 1]) res += H(I, l - 1, r + 1);
  if (l > 1 and s[l - 1] != s[r]) res += H(I, l - 1, r);
  if (r < n and s[l] != s[r + 1]) res += H(I, l, r + 1);
  return h[i][l][r] = res % mod;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> (s + 1) >> K;
  n = strlen(s + 1), m = n + (((n) >> 1) + ((n)&1));
  memset(h, -1, sizeof(h));
  int t = s[1] != s[n];
  h[t][1][n] = 1;
  for (int i = 1; i < n; ++i)
    coe[i - 1][i] = 1, coe[i][i] = 24,
            coe[i][m - (((n - i) >> 1) + ((n - i) & 1))] = H(i, 0, 0);
  coe[0][n] = H(0, 0, 0);
  coe[m][m] = 26;
  for (int j = n; j < m; ++j) coe[j][j] = 25, coe[j][j + 1] = 1;
  int len = (((n + K) >> 1) + ((n + K) & 1)) + 1;
  int ans = 0;
  Matrix res(1), bas = coe;
  while (len) {
    if (len & 1) res = res * bas;
    bas = bas * bas;
    len >>= 1;
  }
  ans = res[0][m];
  if ((n + K) & 1) {
    coe[m][m] = 0;
    for (int i = 0; i < n; ++i) {
      int c = 0;
      for (int j = 1; j < n; ++j)
        if (s[j] == s[j + 1]) c += H(i, j, j + 1);
      coe[i][m - (((n - i) >> 1) + ((n - i) & 1))] = c % mod;
    }
    len = (n + K) / 2 + 2;
    bas = coe;
    res = Matrix(1);
    while (len) {
      if (len & 1) res = res * bas;
      bas = bas * bas;
      len >>= 1;
    }
    ans = (ans - res[0][m] + mod) % mod;
  }
  cout << ans << endl;
  return 0;
}