#agc024e. [agc024_e]Sequence Growing Hard
[agc024_e]Sequence Growing Hard
Problem Statement
Find the number of the possible tuples of sequences that satisfy all of the following conditions, modulo :
- For every , is a sequence of length consisting of integers between and (inclusive);
- For every , is a subsequence of , that is, there exists such that the removal of the -th element of would result in a sequence equal to ;
- For every , is lexicographically larger than .
Constraints
- , and are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of the possible tuples of sequences , modulo .
Sample Input 1
2 2 100
Sample Output 1
5
Five tuples below satisfy the conditions:
Sample Input 2
4 3 999999999
Sample Output 2
358
Sample Input 3
150 150 998244353
Sample Output 3
186248260