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;
bool debug = 1;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long ln, lk, lm;
const int mod = 10007;
char s[225];
int dp[225][225][225], N;
struct Matrix {
  int n, m;
  int a[225 * 2][225 * 2];
  Matrix() {}
  Matrix(int n, int m) : n(n), m(m) {}
  void init(int num) {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) a[i][j] = num;
  }
  Matrix operator*(Matrix b) {
    Matrix o = Matrix(n, b.m);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < b.m; j++) {
        o.a[i][j] = 0;
        for (int k = i; k <= j; k++) {
          o.a[i][j] = (o.a[i][j] + (a[i][k] * b.a[k][j]) % mod) % mod;
        }
      }
    }
    return o;
  }
  Matrix pow(long long p) {
    Matrix o = Matrix(n, m);
    Matrix b = *this;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) o.a[i][j] = (i == j);
    while (p > 0) {
      if (p & 1) o = o * b;
      b = b * b;
      p >>= 1;
    }
    return o;
  }
};
int dfs(int l, int r, int n24) {
  if (dp[l][r][n24] != -1) return dp[l][r][n24];
  int ans = 0;
  if (l == r) {
    ans = n24 == 0;
  } else {
    if (s[l] == s[r]) {
      if (l + 1 == r) {
        ans = n24 == 0;
      } else
        ans = dfs(l + 1, r - 1, n24);
    } else {
      if (n24 > 0) ans = dfs(l + 1, r, n24 - 1) + dfs(l, r - 1, n24 - 1);
    }
  }
  return dp[l][r][n24] = ans % mod;
}
int main() {
  scanf("%s%d", s, &n);
  int l = strlen(s);
  n += l;
  N = (n + 1) / 2;
  int X = l - 1, Y = (l + 1) / 2, Z = Y;
  int S = X + Y + Z;
  Matrix a = Matrix(S, S);
  a.init(0);
  for (int(i) = 0; (i) < (int)(S); (i)++) {
    if (i < X) {
      a.a[i][i] = 24;
      a.a[i][i + 1] = 1;
    } else if (i < X + Y) {
      a.a[i][i] = 25;
      if (i < X + Y - 1) a.a[i][i + 1] = 1;
      a.a[i][X + Y + i - X] = 1;
    } else
      a.a[i][i] = 26;
  }
  Matrix b = a.pow(N - 1);
  Matrix c = b * a;
  memset(dp, -1, sizeof dp);
  int ans = 0;
  for (int(n24) = 0; (n24) < (int)(l); (n24)++) {
    int n25 = (l + 1 - n24) / 2;
    if (N - n24 - n25 < 0) continue;
    int ways = dfs(0, l - 1, n24);
    ans += ways * c.a[X - n24][X + Y + n25 - 1] % mod;
    ans %= mod;
    if (n & 1 && (l - n24) % 2 == 0) {
      int tmp = b.a[X - n24][X + n25 - 1] * ways % mod;
      ans += mod - tmp;
      ans %= mod;
    }
  }
  printf("%d\n", ans);
  return 0;
}