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 mod = 1e4 + 7;
int n, m, t;
char str[205];
int f[205][205][205], g[205];
int h[305][305], r[305][305];
inline void mul(int a[][305], int b[][305], int c[][305]) {
  static int r[305][305];
  for (int i = 0; i <= t; ++i)
    for (int j = i; j <= t; ++j) {
      int f = 0;
      for (int k = i; k <= j; ++k) (f += a[i][k] * b[k][j]) %= mod;
      r[i][j] = f;
    }
  for (int i = 0; i <= t; ++i)
    for (int j = i; j <= t; ++j) c[i][j] = r[i][j];
}
int main() {
  scanf("%s%d", str + 1, &n);
  m = strlen(str + 1);
  f[1][m][0] = 1;
  for (int i = m; i; --i) {
    for (int l = 1, r = i; r <= m; ++l, ++r) {
      if (l == r)
        for (int j = 0; j < m; ++j) (f[l][l - 1][j] += f[l][r][j]) %= mod;
      else if (str[l] == str[r])
        for (int j = 0; j < m; ++j) (f[l + 1][r - 1][j] += f[l][r][j]) %= mod;
      else
        for (int j = 0; j < m; ++j)
          (f[l + 1][r][j + 1] += f[l][r][j]) %= mod,
              (f[l][r - 1][j + 1] += f[l][r][j]) %= mod;
    }
  }
  for (int i = 1; i <= m; ++i)
    for (int j = 0; j < m; ++j) (g[j] += f[i][i - 1][j]) %= mod;
  int A = m - 1, B = m + 1 >> 1, ans;
  t = A + B + 1;
  h[t][t] = 26;
  h[0][A + 1] = g[0];
  r[0][0] = 1;
  for (int i = 1; i <= A; ++i) h[i - 1][i] = 1;
  for (int i = 1; i <= A; ++i) h[i][i] = 24;
  for (int i = A + 1; i < t; ++i) h[i][i] = 25;
  for (int i = A + 2; i <= t; ++i) h[i - 1][i] = 1;
  for (int i = 1; i <= A; ++i) h[i][t - (m - i + 1) / 2] = g[i];
  for (int k = (n + m + 1 >> 1) + 1; k; k >>= 1, mul(h, h, h))
    if (k & 1) mul(r, h, r);
  ans = r[0][t];
  if (n + m & 1) {
    memset(g, 0, sizeof(g));
    memset(h, 0, sizeof(h));
    memset(r, 0, sizeof(r));
    for (int i = 1; i < m; ++i)
      if (str[i] == str[i + 1])
        for (int j = 0; j < m; ++j) (g[j] += f[i][i + 1][j]) %= mod;
    if (!(m & 1)) h[0][t - (m - 2) / 2] = g[0];
    h[t][t] = 25;
    r[0][0] = 1;
    for (int i = 1; i <= A; ++i) h[i - 1][i] = 1;
    for (int i = 1; i <= A; ++i) h[i][i] = 24;
    for (int i = A + 1; i < t; ++i) h[i][i] = 25;
    for (int i = A + 2; i <= t; ++i) h[i - 1][i] = 1;
    for (int i = 1; i <= A; ++i)
      if (!(m - i & 1)) h[i][t - (m - 2 - i) / 2] = g[i];
    for (int k = (n + m >> 1) + 1; k; k >>= 1, mul(h, h, h))
      if (k & 1) mul(r, h, r);
    ans = (ans - r[0][t] + mod) % mod;
  }
  return printf("%d\n", ans), 0;
}