A number is called "nice" if it contains as a subsequence. In other words, if in that number, immediately after the digit there is a digit , then the number is "nice".
For example, the number is "nice", while the number is not "nice".
Task
Given the positive natural numbers and , find the expected number of "nice" numbers in a randomly generated sequence containing numbers with at most digits, modulo .
Input data
The program reads from the keyboard the numbers and , separated by a newline. The number is given in base .
Output data
The program will display on the screen the number , representing the required answer in the form , modulo .
Constraints and clarifications
- The number is given in base .
- The use of fastio is recommended.
- For tests worth points, , .
- For other tests worth points, , .
- For other tests worth points, , .
- For other tests worth points, ;
- For other tests, no additional restrictions.
Example 1
stdin
1
10
stdout
570000004
Explanation
For simplicity, , , so the only allowed nice number is .
There are sequences with "nice" numbers, sequence with "nice" number.
Therefore, the answer is .
Example 2
stdin
5
10
stdout
850000006