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;
int f[210][210][210], cnt;
char s[210];
inline void upd(int &a, int b) { a = (a + b) % 10007; }
int d[410][410], ret[410][410], tmp[410][410];
int main() {
  register int i, j, k, l;
  int n, m, ans = 0, dis;
  scanf("%s%d", s + 1, &n), m = strlen(s + 1), n += m;
  for (i = 1; i <= m; ++i) f[i][i][0] = 1;
  for (i = 1; i < m; ++i)
    if (s[i] != s[i + 1])
      f[i][i + 1][1] = 2;
    else
      f[i][i + 1][0] = 1;
  for (i = 3; i <= m; ++i)
    for (j = 1, k = i; k <= m; ++j, ++k)
      for (l = 0; l <= m; ++l)
        if (s[j] == s[k])
          upd(f[j][k][l], f[j + 1][k - 1][l]);
        else
          upd(f[j][k][l + 1], f[j + 1][k][l]),
              upd(f[j][k][l + 1], f[j][k - 1][l]);
  dis = (m + 1) / 2, cnt = m - 1 + dis + dis;
  for (i = 1; i < m; ++i) d[i][i] = 24, d[i][i + 1] = 1;
  for (i = m; i < m + dis; ++i)
    d[i + dis][i + dis] = 26, d[i][i] = 25, d[i][i + dis] = 1;
  for (i = m; i < m + dis - 1; ++i) d[i][i + 1] = 1;
  for (i = 1; i <= cnt; ++i) ret[i][i] = 1;
  for (l = n / 2; l; l >>= 1) {
    if (l & 1) {
      memset(tmp, 0, sizeof(tmp));
      for (i = 1; i <= cnt; ++i)
        for (k = i; k <= cnt; ++k)
          if (ret[i][k])
            for (j = k; j <= cnt; ++j)
              if (d[k][j]) upd(tmp[i][j], ret[i][k] * d[k][j] % 10007);
      for (i = 1; i <= cnt; ++i)
        for (k = i; k <= cnt; ++k) ret[i][k] = tmp[i][k];
    }
    memset(tmp, 0, sizeof(tmp));
    for (i = 1; i <= cnt; ++i)
      for (k = i; k <= cnt; ++k)
        if (d[i][k])
          for (j = k; j <= cnt; ++j)
            if (d[k][j]) upd(tmp[i][j], d[i][k] * d[k][j] % 10007);
    for (i = 1; i <= cnt; ++i)
      for (k = i; k <= cnt; ++k) d[i][k] = tmp[i][k];
  }
  for (i = 0; i < m; ++i)
    j = (m - i + 1) / 2,
    upd(ans, f[1][m][i] * ret[m - i][m + j - 1 + dis] % 10007);
  if (n & 1)
    for (ans = ans * 26 % 10007, i = 0; i < m; ++i)
      if ((m - i) & 1)
        j = (m - i + 1) / 2,
        upd(ans, f[1][m][i] * ret[m - i][m + j - 1] % 10007);
  printf("%d\n", ans);
}