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 p = 10007;
int n, m, f[510][210][210], a[310][310];
char s[210];
bool odd;
int power(int x, int k) {
  int ret = 1;
  for (; k; k >>= 1, x = x * x % p)
    if (k & 1) ret = ret * x % p;
  return ret;
}
void gauss_elimination(int n) {
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j)
      if (a[j][i]) {
        for (int k = i; k <= n; ++k) swap(a[i][k], a[j][k]);
        swap(a[i][0], a[j][0]);
        break;
      }
    int t = power(a[i][i], p - 2);
    for (int j = i; j <= n; ++j) (a[i][j] *= t) %= p;
    (a[i][0] *= t) %= p;
    for (int j = 1; j <= n; ++j)
      if (i != j && a[j][i]) {
        a[j][0] = (a[j][0] + p - a[j][i] * a[i][0] % p) % p;
        for (int k = n; k >= i; --k)
          a[j][k] = (a[j][k] + p - a[j][i] * a[i][k] % p) % p;
      }
  }
}
int main() {
  scanf("%s%d", s + 1, &m), m += n = strlen(s + 1);
  f[0][1][n] = 1;
  int x = n - 1, y = (n + 1) / 2;
  for (int i = 0; i <= x + y + n; ++i) {
    for (int j = 1; j <= n; ++j)
      for (int k = j; k <= n; ++k)
        if (f[i][j][k])
          if (s[j] == s[k]) {
            (f[i + 1][j][k] += f[i][j][k] * 25) %= p;
            (f[i + 1][j + 1][max(j, k - 1)] += f[i][j][k]) %= p;
          } else {
            (f[i + 1][j][k] += f[i][j][k] * 24) %= p;
            (f[i + 1][j + 1][k] += f[i][j][k]) %= p;
            (f[i + 1][j][k - 1] += f[i][j][k]) %= p;
          }
    for (int j = 0; j <= n; ++j)
      (f[i + 1][j + 1][j] += f[i][j + 1][j] * 26) %= p;
  }
  for (int i = 1; i <= x + y + 1; ++i) {
    for (int j = 0; j <= n; ++j)
      if (m & 1)
        (a[i][0] += f[i + n - 1][j + 1][j] * 26 + f[i + n - 1][j][j]) %= p;
      else
        (a[i][0] += f[i + n][j + 1][j]) %= p;
    int t = power(24, i + n);
    for (int j = 1; j <= x; ++j) a[i][j] = t, (t *= i + n) %= p;
    t = power(25, i + n);
    for (int j = 1; j <= y; ++j) a[i][j + x] = t, (t *= i + n) %= p;
    a[i][x + y + 1] = power(26, i + n);
  }
  gauss_elimination(x + y + 1), m = (m + 1) / 2;
  int ans = power(26, m) * a[x + y + 1][0] % p, t = power(24, m);
  for (int j = 1; j <= x; ++j) (ans += a[j][0] * t) %= p, (t *= m % p) %= p;
  t = power(25, m);
  for (int j = 1; j <= y; ++j) (ans += a[j + x][0] * t) %= p, (t *= m % p) %= p;
  printf("%d\n", ans);
  return 0;
}