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 std::cerr;
using std::endl;
const int N = 305, P = 1e4 + 7;
char str[N];
int n, m, ans;
int id[N][2], num;
struct Matrix {
  int mat[N][N];
  Matrix() { memset(mat, 0, sizeof(mat)); }
  inline int *operator[](int x) { return mat[x]; }
};
inline Matrix operator*(Matrix &a, Matrix &b) {
  Matrix ret;
  for (int i = 1; i <= num; ++i)
    for (int k = i; k <= num; ++k)
      for (int j = k; j <= num; ++j)
        ret[i][j] = (ret[i][j] + a[i][k] * b[k][j]) % P;
  return ret;
}
inline Matrix fpow(Matrix x, int y) {
  Matrix ret = x;
  for (--y; y; y >>= 1, x = x * x)
    if (y & 1) ret = ret * x;
  return ret;
}
int mem[N][N][N], tag[N][N][N], now, ban;
int dfs(int l, int r, int i) {
  if (i < 0) return 0;
  if (r + 2 == l) return !i && !ban;
  if (r + 1 == l) return !i;
  if (tag[l][r][i] == now) return mem[l][r][i];
  int ret = 0;
  if (str[l] == str[r])
    ret = dfs(l + 1, r - 1, i);
  else
    ret = (dfs(l + 1, r, i - 1) + dfs(l, r - 1, i - 1)) % P;
  tag[l][r][i] = now;
  return mem[l][r][i] = ret;
}
Matrix F, G, bF, bG;
int main() {
  scanf("%s %d", str + 1, &n);
  m = strlen(str + 1), n += m;
  now = 1;
  for (int i = 0; i <= m; ++i) dfs(1, m, i);
  for (int i = 1; i <= m; ++i) id[i][0] = ++num;
  for (int i = (m + 1) / 2; ~i; --i) id[i][1] = ++num;
  for (int i = 1; i <= m; ++i) G[id[i][0]][id[i][0]] = 24;
  for (int i = 1; i <= (m + 1) / 2; ++i) G[id[i][1]][id[i][1]] = 25;
  G[id[0][1]][id[0][1]] = 26;
  for (int i = 1; i < m; ++i) G[id[i][0]][id[i + 1][0]] = 1;
  for (int i = (m + 1) / 2; i; --i) G[id[i][1]][id[i - 1][1]] = 1;
  for (int i = 1; i <= m; ++i) {
    int way = mem[1][m][i];
    int j = (m - i + 1) >> 1;
    G[id[i][0]][id[j][1]] = way;
  }
  F[1][id[1][0]] = 1;
  F[1][id[(m + 1) / 2][1]] = mem[1][m][0];
  bF = F, bG = G;
  G = fpow(G, (n + 1) >> 1);
  F = F * G;
  ans = F[1][id[0][1]];
  if (!(n & 1)) {
    std::cout << ans << '\n';
    return 0;
  }
  ban = 1, now = 2;
  for (int i = 0; i <= m; ++i) dfs(1, m, i);
  F = bF, G = bG;
  for (int i = 1; i <= m; ++i) {
    int way = mem[1][m][i];
    int j = (m - i + 1) >> 1;
    G[id[i][0]][id[j][1]] = way;
  }
  G[id[0][1]][id[0][1]] = 0;
  F[1][id[(m + 1) / 2][1]] = mem[1][m][0];
  G = fpow(G, (n + 1) >> 1);
  F = F * G;
  ans = (ans + P - F[1][id[0][1]]) % P;
  std::cout << ans << '\n';
  return 0;
}