#agc049d. [agc049_d]Convex Sequence
[agc049_d]Convex Sequence
Problem Statement
Given are integers and . Find the number, modulo , of length- sequences that consist of non-negative integers and satisfy the following conditions:
- ;
- For every (), .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number, modulo , of sequences that satisfy the conditions.
Sample Input 1
3 3
Sample Output 1
7
The following seven sequences satisfy the conditions.
Sample Input 2
10 100
Sample Output 2
10804516
Sample Input 3
10000 100000
Sample Output 3
694681734