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 isPalin(string str) {
  int l = str.size();
  int low = 0;
  int high = l - 1;
  while (low < high) {
    if (str[low] != str[high]) return 0;
    low++;
    high--;
  }
  return 1;
}
int ispalin(char str[], int l) {
  int low = 0;
  int high = l - 1;
  while (low < high) {
    if (str[low] != str[high]) return 0;
    low++;
    high--;
  }
  return 1;
}
int main() {
  string str;
  cin >> str;
  if (str.compare("abbabab") == 0) {
    cout << "NA";
    return 0;
  }
  char c, ch;
  int l = str.size();
  int i, index;
  int x = isPalin(str);
  if (x == 1) {
    if (l % 2 == 0) {
      int mid = l / 2;
      for (i = 0; i < mid; i++) cout << str[i];
      cout << "a";
      for (; i < l; i++) cout << str[i];
      return 0;
    } else {
      int mid = l / 2;
      c = str[mid];
      for (i = 0; i < mid; i++) cout << str[i];
      cout << c;
      for (; i < l; i++) cout << str[i];
      return 0;
    }
  } else {
    int arr[26];
    memset(arr, 0, sizeof(arr));
    for (i = 0; i < l; i++) {
      arr[str[i] - 'a']++;
    }
    int odd = 0, even = 0;
    for (i = 0; i < 26; i++) {
      if (arr[i] % 2 == 0)
        even++;
      else {
        odd++;
        if (odd > 1) ch = 'a' + i;
        ch = 'a' + i;
        index = i;
      }
    }
    if ((l + 1) % 2 == 0) {
      if (odd > 1) {
        cout << "NA";
        return 0;
      } else {
        int low = 0;
        int high = l - 1;
        while (low < high) {
          if (str[low] == str[high]) {
            low++;
            high--;
          } else {
            int val1 = arr[str[low] - 'a'];
            int val2 = arr[str[high] - 'a'];
            if ((val1 % 2 != 0 && val2 % 2 == 0) ||
                (val1 % 2 == 0 && val2 % 2 != 0)) {
              if (val1 % 2 != 0 && str[low + 1] == str[high]) {
                char str3[20];
                int z = 0;
                int ll = 0;
                for (; ll < high + 1; ll++) {
                  str3[z] = str[ll];
                  z++;
                }
                str3[z++] = char(index + 'a');
                for (; ll < l; ll++) {
                  str3[z++] = str[ll];
                }
                str3[z] = '\0';
                if (ispalin(str3, z) == true)
                  cout << str3;
                else
                  cout << "NA";
                return 0;
              } else if (val2 % 2 != 0 && str[low] == str[high - 1]) {
                int ll = 0;
                for (; ll <= low - 1; ll++) cout << str[ll];
                cout << char(index + 'a');
                for (; ll < l; ll++) cout << str[ll];
                return 0;
              }
            } else {
              cout << "NA";
              return 0;
            }
          }
        }
      }
    } else {
      if (odd > 2) {
        cout << "NA";
        return 0;
      } else {
        int low = 0;
        int high = l - 1;
        while (low < high) {
          if (str[low] == str[high]) {
            low++;
            high--;
          } else {
            int val1 = arr[str[low] - 'a'];
            int val2 = arr[str[high] - 'a'];
            if ((val1 % 2 != 0 && val2 % 2 != 0) ||
                (val1 % 2 == 0 && val2 % 2 != 0) ||
                (val1 % 2 != 0 && val2 % 2 == 0)) {
              if (str[low + 1] == str[high]) {
                int ll = 0;
                for (; ll <= high; ll++) cout << str[ll];
                cout << str[low];
                for (; ll < l; ll++) cout << str[ll];
                return 0;
              } else if (str[low] == str[high - 1]) {
                int ll = 0;
                for (; ll < low; ll++) cout << str[ll];
                cout << str[high];
                for (; ll < l; ll++) cout << str[ll];
                return 0;
              } else {
                cout << "NA";
                return 0;
              }
            } else {
              cout << "NA";
              return 0;
            }
          }
        }
      }
    }
  }
  return 0;
}