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 = 200 + 2;
int pow(int x, int n) {
  if (n <= 1) return n ? x : 1;
  int tmp = pow(x, n / 2);
  if (n % 2)
    return (tmp * tmp % 10007) * x % 10007;
  else
    return tmp * tmp % 10007;
}
struct mat {
  int n, m, a[maxn * 3 / 2][maxn * 3 / 2];
  mat(int _n, int _m) {
    n = _n, m = _m;
    memset(a, 0, sizeof(a));
  }
};
mat mul(const mat &p, const mat &q) {
  mat r(p.n, q.m);
  for (int i = 0; i < p.n; i++)
    for (int j = 0; j < q.m; j++)
      for (int k = 0; k < p.m; k++)
        r.a[i][j] += p.a[i][k] * q.a[k][j], r.a[i][j] %= 10007;
  return r;
}
int getnum(mat &p, int st, int ed, int K) {
  mat q(p.n, 1);
  q.a[st][0] = 1;
  for (; K; K >>= 1, p = mul(p, p))
    if (K & 1) q = mul(p, q);
  return q.a[ed][0];
}
int t[maxn][maxn];
int solve(int *d, int n, int K, int type) {
  memset(t, 0, sizeof(t));
  int ha = (n + 1) / 2;
  for (int i = 0; i <= n; i++) t[i][(n - i + 1) / 2] = d[i];
  for (int i = 0; i < n; i++)
    for (int j = 1; j <= ha; j++)
      t[i + 1][j] = (t[i + 1][j] + t[i][j]) % 10007,
            t[i + 1][j - 1] = (t[i + 1][j - 1] + t[i][j]) % 10007, t[i][j] = 0;
  int GOAL = 0;
  mat p(n + ha + 1, n + ha + 1);
  for (int i = 2; i <= n + ha; i++) p.a[i][i - 1] = 1;
  for (int i = 1; i <= n + ha; i++) p.a[i][i] = (i <= n ? 24 : 25);
  for (int i = ha; i <= n + ha; i++)
    p.a[GOAL][i] = (i <= n ? t[i][0] : t[n][i - n]);
  p.a[GOAL][GOAL] = (type == 1 ? 26 : 25);
  return getnum(p, 1, 0, K);
}
char s[maxn];
int dp[maxn][maxn][maxn];
void DP(int n, int type) {
  memset(dp, 0, sizeof(dp));
  for (int i = n; i >= 1; i--)
    for (int j = i; j <= n; j++) {
      if (type == 1) {
        if (i == j) {
          dp[i][j][0] = 1;
          continue;
        }
      } else {
        if (i == j) continue;
        if (j == i + 1) {
          dp[i][j][0] = (s[i] == s[j] ? 1 : 0);
          continue;
        }
      }
      if (s[i] == s[j]) {
        for (int k = 0; k <= n; k++) dp[i][j][k] = dp[i + 1][j - 1][k];
        if (j == i + 1) dp[i][j][0] = 1;
      } else {
        dp[i][j][0] = 0;
        for (int k = 1; k <= n; k++)
          dp[i][j][k] = (dp[i + 1][j][k - 1] + dp[i][j - 1][k - 1]) % 10007;
      }
    }
}
int main() {
  int n, m;
  scanf("%s%d", s + 1, &m);
  n = strlen(s + 1);
  DP(n, 1);
  int K = (n + m + 1) / 2;
  int ans = solve(dp[1][n], n, K, 1);
  if (n == 1 || (n + m) % 2 == 0) {
    printf("%d\n", ans);
    return 0;
  }
  if (n == 2 && s[1] == s[2])
    ans = (ans - pow(25, K - 1) + 10007) % 10007;
  else if (n != 2) {
    DP(n, 2);
    ans = (ans - solve(dp[1][n], n - 2, K - 1, 2) + 10007) % 10007;
  }
  printf("%d\n", ans);
}