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;
struct M {
  int a[410][410];
  int r, c;
  M(int rr = 0, int cc = 0) {
    memset(a, 0, sizeof(a));
    r = rr;
    c = cc;
  }
  void init(int x) {
    memset(a, 0, sizeof(a));
    r = c = x;
    for (int i = 1; i <= x; i++) a[i][i] = 1;
    return;
  }
  void clear() { memset(a, 0, sizeof(a)); }
};
M tmp;
M operator*(const M& a, const M& b) {
  tmp.clear();
  tmp.r = a.r;
  tmp.c = b.c;
  for (int i = 1; i <= tmp.r; i++)
    for (int j = i; j <= tmp.c; j++)
      for (int k = i; k <= j; k++)
        tmp.a[i][j] = (tmp.a[i][j] + a.a[i][k] * b.a[k][j]) % 10007;
  return tmp;
}
M t, ans;
M fpow(const M& a, int b) {
  ans.init(a.r);
  t = a;
  while (b) {
    if (b & 1) ans = ans * t;
    t = t * t;
    b >>= 1;
  }
  return ans;
}
char str[210];
int dp[210][210][210];
int num[210];
void add(int& x, int y) {
  x += y;
  if (x >= 10007) x -= 10007;
  return;
}
M A, res;
int main() {
  int n, len, N;
  scanf("%s", str + 1);
  len = strlen(str + 1);
  scanf("%d", &n);
  N = len + n;
  bool flag = N & 1;
  N = (N + 1) / 2;
  dp[1][len][0] = 1;
  for (int l = len; l >= 1; l--) {
    for (int i = 1; i + l - 1 <= len; i++) {
      int j = i + l - 1;
      int val = (str[i] == str[j]);
      for (int k = 0; k <= len - l; k++) {
        if (val) {
          if (l == 1)
            add(dp[i][j - 1][k], dp[i][j][k]);
          else
            add(dp[i + 1][j - 1][k], dp[i][j][k]);
        } else {
          add(dp[i][j - 1][k + 1], dp[i][j][k]);
          add(dp[i + 1][j][k + 1], dp[i][j][k]);
        }
      }
    }
  }
  for (int i = 1; i <= len; i++)
    for (int k = 0; k <= len; k++) add(num[k], dp[i][i - 1][k]);
  int ss = len / 2 + (len & 1);
  int s = len + ss * 2;
  A.r = A.c = s;
  for (int i = 1; i <= len; i++) A.a[i][i] = 24, A.a[i][i + 1] = 1;
  for (int i = 1; i <= ss; i++) {
    if (i < ss) A.a[len + i][len + i + 1] = 1;
    A.a[len + i][len + i] = 25;
    A.a[len + i][len + ss + i] = 1;
    A.a[len + ss + i][len + ss + i] = 26;
  }
  res = fpow(A, N);
  int sum = 0;
  for (int i = 0; i <= len; i++) {
    int j = (len - i + 1) / 2;
    sum = (sum + res.a[len - i + 1][len + ss + j] * num[i]) % 10007;
  }
  if (flag) {
    res = fpow(A, N - 1);
    for (int i = 0; i <= len; i++) {
      int j = len - i;
      if (j & 1) continue;
      j /= 2;
      sum =
          (sum - res.a[len - i + 1][len + j] * num[i] % 10007 + 10007) % 10007;
    }
  }
  printf("%d\n", sum);
  return 0;
}