#agc035e. [agc035_e]Develop
[agc035_e]Develop
Problem Statement
There is a blackboard on which all integers from through are written, each of them appearing once. Takahashi will repeat the following sequence of operations any number of times he likes, possibly zero:
- Choose an integer between and (inclusive) that is written on the blackboard. Let be the chosen integer, and erase .
- If is not written on the blackboard, write on the blackboard.
- If is not written on the blackboard, write on the blackboard.
Find the number of possible sets of integers written on the blackboard after some number of operations, modulo . We consider two sets different when there exists an integer contained in only one of the sets.
Constraints
- , , and are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of possible sets of integers written on the blackboard after some number of operations, modulo .
Sample Input 1
3 1 998244353
Sample Output 1
7
Every set containing all integers less than , all integers greater than , and at least one of the three integers , , and satisfies the condition. There are seven such sets.
Sample Input 2
6 3 998244353
Sample Output 2
61
Sample Input 3
9 4 702443618
Sample Output 3
312
Sample Input 4
17 7 208992811
Sample Output 4
128832
Sample Input 5
123 45 678901234
Sample Output 5
256109226