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;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch - '0' < 0 || ch - '0' > 9) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch - '0' >= 0 && ch - '0' <= 9) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m, cnt, N;
char s[205];
int id[205][205];
int head[205 * 205], nxt[205 * 205 * 2], to[205 * 205 * 2], tot;
void add(int u, int v) {
  tot++;
  nxt[tot] = head[u];
  head[u] = tot;
  to[tot] = v;
}
int book[205 * 205];
int vis[205 * 205][205], f[205 * 205][205];
void addx(int &x, int y) { x = (x + y) % 10007; }
int ans;
int dfs(int x, int c) {
  if (c < 0) return 0;
  if (vis[x][c]) return f[x][c];
  vis[x][c] = 1;
  for (int i = head[x]; i; i = nxt[i]) addx(f[x][c], dfs(to[i], c - book[x]));
  return f[x][c];
}
int b[205 * 2][205 * 2], a[205 * 2][205 * 2];
void mul(int A[205 * 2][205 * 2], int B[205 * 2][205 * 2],
         int C[205 * 2][205 * 2]) {
  int tmp[205 * 2][205 * 2];
  memset(tmp, 0, sizeof(tmp));
  for (int i = 1; i <= N; i++) {
    for (int k = i; k <= N; k++) {
      for (int j = k; j <= N; j++) addx(tmp[i][j], A[i][k] * B[k][j]);
    }
  }
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++) C[i][j] = tmp[i][j];
}
void quick_pow(int p) {
  for (int i = 1; i <= N; i++) a[i][i] = 1;
  while (p) {
    if (p & 1) mul(a, b, a);
    mul(b, b, b);
    p >>= 1;
  }
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  m = read();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) id[i][j] = ++cnt;
  cnt++;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      if (s[i] == s[j] && j - i <= 1)
        add(cnt, id[i][j]);
      else if (s[i] == s[j])
        add(id[i + 1][j - 1], id[i][j]);
      else {
        add(id[i][j - 1], id[i][j]);
        add(id[i + 1][j], id[i][j]);
        book[id[i][j]] = 1;
      }
    }
  }
  for (int i = 0; i < n; i++) vis[id[1][n]][i] = 1;
  f[id[1][n]][book[id[1][n]]] = 1;
  for (int i = 0; i < n; i++) dfs(cnt, i);
  int nx = (n + 1) / 2;
  for (int i = 1; i <= n - 1; i++) b[i][i] = 24;
  for (int i = 1; i < n + nx - 1; i++) b[i][i + 1] = 1;
  for (int i = n; i < n + nx; i++) b[i][i + nx] = 1, b[i][i] = 25;
  for (int i = n + nx; i < n + 2 * nx; i++) b[i][i] = 26;
  N = n - 1 + 2 * nx;
  quick_pow((n + m) / 2);
  for (int i = 0; i < n; i++) {
    int x = (n - i + 1) / 2;
    addx(ans, f[cnt][i] * a[n - i][n + nx + x - 1]);
  }
  if ((n + m) & 1) {
    ans = ans * 26 % 10007;
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < n; j++) {
        int x = (n - j + 1) / 2;
        addx(ans, f[id[i][i]][j] * a[n - j][n + x - 1]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}