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 kMod = 10007;
char buf[222];
int m, n, l;
int dp[222][222][222];
int f[222];
int s;
struct Matrix {
  int v[444][444];
  void clear() { memset(v, 0, sizeof(v)); }
} I, A, F;
Matrix operator*(const Matrix &a, const Matrix &b) {
  Matrix c;
  c.clear();
  for (int i = 0; i < s; ++i)
    for (int k = 0; k <= i; ++k)
      if (a.v[i][k])
        for (int j = 0; j <= k; ++j)
          if (b.v[k][j]) c.v[i][j] = (c.v[i][j] + a.v[i][k] * b.v[k][j]) % kMod;
  return c;
}
Matrix powMod(const Matrix &a, int b) {
  Matrix res = I, tmp = a;
  while (b) {
    if (b & 1) res = res * tmp;
    b >>= 1;
    tmp = tmp * tmp;
  }
  return res;
}
int main() {
  scanf("%s", buf + 1);
  m = strlen(buf + 1);
  scanf("%d", &n);
  l = m + n;
  if (buf[1] != buf[m]) {
    dp[0][0][1] = 1;
  } else {
    dp[0][0][0] = 1;
  }
  for (int l = 0; l < m; ++l) {
    for (int r = 0; r < m - l; ++r) {
      for (int k = 0; k < 222; ++k)
        if (dp[l][r][k]) {
          if (buf[l + 1] != buf[m - r]) {
            int i, j;
            i = l + 1, j = r;
            if (buf[i + 1] != buf[m - j]) {
              dp[i][j][k + 1] += dp[l][r][k];
              dp[i][j][k + 1] %= kMod;
            } else {
              dp[i][j][k] += dp[l][r][k];
              dp[i][j][k] %= kMod;
            }
            i = l, j = r + 1;
            if (buf[i + 1] != buf[m - j]) {
              dp[i][j][k + 1] += dp[l][r][k];
              dp[i][j][k + 1] %= kMod;
            } else {
              dp[i][j][k] += dp[l][r][k];
              dp[i][j][k] %= kMod;
            }
          } else {
            int i, j;
            i = l + 1, j = r + 1;
            if (i + j >= m) {
              f[k] += dp[l][r][k];
              f[k] %= kMod;
            } else {
              if (buf[i + 1] != buf[m - j]) {
                dp[i][j][k + 1] += dp[l][r][k];
                dp[i][j][k + 1] %= kMod;
              } else {
                dp[i][j][k] += dp[l][r][k];
                dp[i][j][k] %= kMod;
              }
            }
          }
        }
    }
  }
  s = (m - 1) + ((m - 1) / 2 + 1) * 2;
  for (int i = 0; i < s; ++i) I.v[i][i] = 1;
  for (int i = 0; i < m - 1; ++i) {
    A.v[i + 1][i]++;
    A.v[i][i] += 24;
  }
  for (int i = m - 1; i < (m - 1) + ((m - 1) / 2 + 1); ++i) {
    if (i + 1 < (m - 1) + ((m - 1) / 2) + 1) A.v[i + 1][i]++;
    A.v[i][i] += 25;
    A.v[(m - 1) + ((m - 1) / 2 + 1) + (i - (m - 1))][i]++;
  }
  for (int i = (m - 1) + ((m - 1) / 2 + 1); i < s; ++i) {
    A.v[i][i] += 26;
  }
  for (int i = 0; i < m; ++i) {
    F.v[i][i] = 1;
  }
  F = powMod(A, (l - 1) / 2 + 1) * F;
  int ans = 0;
  for (int k = 0; k < 222; ++k)
    if (f[k]) {
      int n24 = k, n25 = (m - k - 1) / 2 + 1;
      int from = (m - 1) - k;
      int to = (m - 1) + ((m - 1) / 2 + 1) + n25 - 1;
      ans = (ans + F.v[to][from] * f[k]) % kMod;
    }
  if (l & 1) {
    F.clear();
    for (int i = 0; i < m; ++i) {
      F.v[i][i] = 1;
    }
    F = powMod(A, (l - 1) / 2) * F;
    for (int k = 0; k < 222; ++k)
      if (f[k]) {
        int n24 = k, n25 = (m - k - 1) / 2 + 1;
        if ((m - n24) % 2 == 0) {
          int from = (m - 1) - k;
          int to = (m - 1) + n25 - 1;
          ans -= F.v[to][from] * f[k] % kMod;
          if (ans < 0) ans += kMod;
        }
      }
  }
  printf("%d\n", ans);
  return 0;
}