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 N = 5005, mod = 1e4 + 7;
namespace {
inline int add(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }
inline void Add(int &x, int y) { x = add(x, y); }
inline int mnu(int x, int y) { return x - y < 0 ? x - y + mod : x - y; }
inline int mul(int x, int y) { return (long long)x * y % mod; }
inline int power(int x, long long p) {
  int res = 1;
  for (; p; p >>= 1, x = (long long)x * x % mod)
    if (p & 1) res = (long long)res * x % mod;
  return res;
}
}  // namespace
namespace LS {
int p[N], d[N], m;
vector<int> s[N];
vector<int> BM(vector<int> a) {
  int n = a.size();
  for (; m;) s[m--].clear();
  for (int i = (0); i < (n); i++) {
    d[i] = a[i];
    for (int j = (0); j < (s[m].size()); j++)
      d[i] = mnu(d[i], mul(a[i - j - 1], s[m][j]));
    if (!d[i]) continue;
    p[m] = i;
    if (!m) {
      s[++m].resize(i + 1);
      continue;
    }
    int id = m - 1;
    for (int j = (0); j < (m - 1); j++)
      id = (p[j] - s[j].size() > p[id] - s[id].size() ? j : id);
    int coef = mul(d[i], power(d[p[id]], mod - 2));
    s[++m].resize(i - p[id] - 1);
    s[m].push_back(coef);
    for (int j = (0); j < (s[id].size()); j++)
      s[m].push_back(mul(mod - coef, s[id][j]));
    for (int j = (0); j < (s[m - 1].size()); j++)
      if (j < s[m].size())
        s[m][j] = add(s[m][j], s[m - 1][j]);
      else
        s[m].push_back(s[m - 1][j]);
  }
  return s[m];
}
const long long Mod = (long long)mod * mod * 8;
int A[N], B[N], bin[N], res[N], n;
inline void Mul(int *x, int *y) {
  static long long t[N << 1];
  for (int k = (0); k <= (n * 2 - 2); k++) t[k] = 0;
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (n); j++)
      t[i + j] += (long long)x[i] * y[j],
          (t[i + j] >= Mod ? t[i + j] -= Mod : 0);
  ;
  for (int i = (n * 2 - 2); i >= (n); i--) {
    t[i] %= mod;
    for (int j = (0); j < (n); j++)
      t[i - j - 1] += t[i] * A[j],
          (t[i - j - 1] >= Mod ? t[i - j - 1] -= Mod : 0);
    ;
    t[i] = 0;
  }
  for (int i = (0); i < (n); i++) x[i] = t[i] % mod;
}
int solve(vector<int> a, vector<int> b, long long K) {
  n = a.size();
  if (K <= n - 1) return b[K];
  if (n == 1) return mul(b[0], power(a[0], K));
  for (int i = (0); i < (n); i++) {
    bin[i] = res[i] = 0;
    A[i] = a[i], B[i] = b[i];
  }
  bin[1] = res[0] = 1;
  for (K -= n - 1; K; K >>= 1, Mul(bin, bin))
    if (K & 1) Mul(res, bin);
  for (int i = (n); i <= (n * 2 - 2); i++) {
    B[i] = 0;
    for (int j = (0); j < (n); j++) B[i] = add(B[i], mul(B[i - j - 1], A[j]));
  }
  int s = 0;
  for (int i = (0); i < (n); i++) s = add(s, mul(B[n - 1 + i], res[i]));
  return s;
}
int gao(vector<int> x, long long K) { return solve(BM(x), x, K); }
}  // namespace LS
const int M = 205;
int dp[M * 4][M][M], done[M * 4];
int len, n, m;
char s[M];
vector<int> ans;
int main() {
  scanf("%s%d", s + 1, &n);
  len = strlen(s + 1), m = len * 8 + 5;
  dp[0][1][len] = 1;
  for (int i = (1); i <= (len * 4 + 5); i++) {
    done[i] = (long long)done[i - 1] * 26 % mod;
    for (int l = (1); l <= (len); l++)
      for (int r = (l); r <= (len); r++)
        if (s[l] == s[r]) {
          if (l + 1 > r - 1)
            Add(done[i], dp[i - 1][l][r]);
          else
            Add(dp[i][l + 1][r - 1], dp[i - 1][l][r]);
          Add(dp[i][l][r], mul(dp[i - 1][l][r], 25));
        } else {
          Add(dp[i][l + 1][r], dp[i - 1][l][r]);
          Add(dp[i][l][r - 1], dp[i - 1][l][r]);
          Add(dp[i][l][r], mul(dp[i - 1][l][r], 24));
        }
  }
  ans.resize(m + 1);
  for (int i = (1); i <= (m); i++)
    if (i & 1) {
      ans[i] = mul(done[i / 2], 26);
      for (int j = (1); j <= (len); j++) Add(ans[i], dp[i / 2][j][j]);
    } else
      ans[i] = done[i / 2];
  cout << LS::gao(ans, n + len) << endl;
  return 0;
}