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 e = 205, o = e << 1, mod = 1e4 + 7;
int ans, m, n, a[o][o], b[o], f[e][e][e], cnt, c[o][o], d[o];
bool vis[e][e][e];
char s[e];
inline void add(int &x, int y) { (x += y) >= mod && (x -= mod); }
inline int plu(int x, int y) {
  add(x, y);
  return x;
}
inline void del(int &x, int y) { (x -= y) < 0 && (x += mod); }
inline int dfs(int x, int l, int r) {
  if (x < 0) return 0;
  if (vis[x][l][r]) return f[x][l][r];
  vis[x][l][r] = 1;
  int &res = f[x][l][r];
  if (l > r) {
    if (!x)
      res = 1;
    else
      res = 0;
  } else {
    if (s[l] == s[r])
      res = dfs(x, l + 1, r - 1);
    else
      res = plu(dfs(x - 1, l + 1, r), dfs(x - 1, l, r - 1));
  }
  return res;
}
inline void merge() {
  int i, j, k;
  for (i = 1; i <= cnt; i++)
    for (j = 1; j <= cnt; j++) c[i][j] = a[i][j], a[i][j] = 0;
  for (i = 1; i <= cnt; i++)
    for (k = i; k <= cnt; k++)
      for (j = k; j <= cnt; j++) a[i][j] = (a[i][j] + c[i][k] * c[k][j]) % mod;
}
inline void join() {
  int i, j, k;
  for (i = 1; i <= cnt; i++) d[i] = b[i], b[i] = 0;
  for (k = 1; k <= cnt; k++)
    for (j = k; j <= cnt; j++) b[j] = (b[j] + d[k] * a[k][j]) % mod;
}
inline void ksm(int y) {
  y++;
  while (y) {
    if (y & 1) join();
    y >>= 1;
    merge();
  }
}
inline int div2(int x) { return (x >> 1) + (x & 1); }
inline int id1(int x) { return x + 1; }
inline int id2(int x) { return x + m + 1; }
inline void build() {
  int i, j;
  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));
  for (i = 0; i <= m; i++) {
    int x = id1(i);
    a[x][x] = 24;
    if (i != m) a[x][x + 1] = 1;
    int j = div2(m - i), y = id2(div2(m) - j + 1);
    if (m + 2 <= y && y <= id2(div2(m))) {
      a[x][y] = dfs(i, 1, m);
    }
  }
  for (i = 1; i <= div2(m); i++) {
    int x = id2(i);
    a[x][x] = 25;
    a[x][x + 1] = 1;
  }
  a[cnt][cnt] = 26;
  a[1][1] = 0;
  b[1] = 1;
}
int main() {
  scanf("%s", s + 1);
  m = strlen(s + 1);
  cin >> n;
  n += m;
  int i;
  cnt = div2(m) + 2 + m;
  build();
  ksm(div2(n));
  ans = b[cnt];
  if (n & 1) {
    build();
    a[cnt][cnt] = 0;
    for (i = 0; i <= m; i++) {
      int x = id1(i);
      int j = div2(m - i), y = id2(div2(m) - j + 1);
      if (y >= m + 2 && (2 * j + i != m)) a[x][y] = 0;
    }
    ksm(div2(n));
    del(ans, b[cnt]);
  }
  cout << ans << endl;
  return 0;
}