Substring of a Palindrome
Some generous person has kindly given you a string consisting of lowercase English letters. You are asked to insert exactly lowercase English letters into 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 "codeforces"
are not.) You can choose any lowercase English letters, and insert each of them to any position of , possibly to the beginning or the end of . You must insert exactly letters even if it is possible to turn into a palindrome by inserting less than letters.
Find the number of the palindromes that can be obtained in this way, modulo .
Input
The first line contains a string . Each character in is a lowercase English letter.
The second line contains an integer .
Output
Print the number of the palindromes that can be obtained, modulo .
Examples
For the first sample, you can obtain the palindrome "reviver"
by inserting 'r'
to the end of "revive"
.
For the second sample, the following palindromes can be obtained: "adada"
, "adbda"
, ..., "adzda"
, "dadad"
and "ddadd"
.