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;
long long gi() {
  long long ret = 0;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  char c = ch == '-' ? getchar() : ch;
  while (c >= '0' && c <= '9') ret = ret * 10 + c - '0', c = getchar();
  return ch == '-' ? -ret : ret;
}
const int N = 410 + 10;
const int mo = 10007;
int n, len, f[N][N][N], G[N], r[N], g[N], e[N], alc;
char s[N];
struct Mat {
  int a[N][N];
} M, M1;
Mat operator*(const Mat &x, const Mat &y) {
  Mat ret = {0};
  for (int i = 1; i <= alc; i += 1)
    for (int j = 1; j <= alc; j += 1)
      if (x.a[i][j])
        for (int k = 1; k <= alc; k += 1)
          if (y.a[j][k]) (ret.a[i][k] += x.a[i][j] * y.a[j][k]) %= mo;
  return ret;
}
Mat ksm(Mat a, int b) {
  Mat ret = {0};
  for (int i = 1; i <= alc; i += 1) ret.a[i][i] = 1;
  while (b) {
    if (b & 1) ret = ret * a;
    a = a * a;
    b >>= 1;
  }
  return ret;
}
int main() {
  scanf("%s", s + 1);
  len = strlen(s + 1);
  n = gi() + len;
  f[1][len][0] = 1;
  for (int d = len - 1; d >= 0; d -= 1)
    for (int i = 1; i + d <= len; i += 1) {
      int j = i + d;
      for (int k = 0; k <= len; k += 1)
        if (f[i][j][k]) {
          if (s[i] == s[j]) {
            if (i == j)
              (G[k] += f[i][j][k]) %= mo;
            else if (i + 1 == j)
              (G[k] += f[i][j][k]) %= mo;
            else
              (f[i + 1][j - 1][k] += f[i][j][k]) %= mo;
          } else {
            (f[i + 1][j][k + 1] += f[i][j][k]) %= mo;
            (f[i][j - 1][k + 1] += f[i][j][k]) %= mo;
          }
        }
    }
  for (int i = 1; i < len; i += 1) r[i] = ++alc, M.a[r[i]][r[i]] = 24;
  for (int i = 2; i < len; i += 1) M.a[r[i - 1]][r[i]] = 1;
  for (int i = 1; i <= (len + 1) / 2; i += 1)
    g[i] = ++alc, M.a[g[i]][g[i]] = 25;
  for (int i = 2; i <= (len + 1) / 2; i += 1) M.a[g[i - 1]][g[i]] = 1;
  M.a[r[len - 1]][g[1]] = 1;
  for (int i = 1; i <= (len + 1) / 2; i += 1)
    e[i] = ++alc, M.a[g[i]][e[i]] = 1, M.a[e[i]][e[i]] = 26;
  M1 = ksm(M, (n + 1) / 2 - 1);
  M = ksm(M, (n + 1) / 2);
  long long ans = 0;
  for (int i = 0; i < len; i += 1) {
    (ans += G[i] * M.a[len - i][e[(len - i + 1) / 2]]) %= mo;
  }
  if (n & 1)
    for (int i = 0; i < len; i += 1)
      if ((len - i) % 2 == 0) {
        (ans -= G[i] * M1.a[len - i][g[(len - i + 1) / 2]]) %= mo;
      }
  cout << (ans + mo) % mo;
  return 0;
}