#Lutece1577. Joyful Palindr0me
Joyful Palindr0me
Migrated from Lutece 1577 Joyful Palindr0me
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
A Palindrome string is a string which reads the same backward as forward, such as madam or racecar.
There is a problem about the palindrome string again.
We define the palindrome level of a string equals the number of the distinct palindrome substrings of .
For example, "aa'' has the palindrome level and "aba'' has the palindrome level .
Consider all the strings with the length and the charset size , calculate the sum of their palindrome levels.
Input
Only one line contains two integers and .
, .
Output
Print the corresponding answer modulo .
Samples
3 2
24
2 3
18
Resources
The 15th UESTC Programming Contest Final