#abc299h. [abc299_h]Dice Sum Infinity
[abc299_h]Dice Sum Infinity
Problem Statement
Takahashi has an unbiased six-sided die and a positive integer less than . Each time the die is cast, it shows one of the numbers with equal probability, independently of the outcomes of the other trials.
Takahashi will perform the following procedure. Initially, .
- Cast the die and increment by .
- Let be the sum of the numbers shown so far. If is a multiple of , quit the procedure.
- Go back to step 1.
Find the expected value of at the end of the procedure, modulo .
Notes
Under the constraints of this problem, it can be shown that the expected value of is represented as an irreducible fraction , and there is a unique integer such that . Print this .
Constraints
- is an integer.
Input
The input is given from Standard Input in the following format:
Output
Print a single line containing the answer.
Sample Input 1
1
Sample Output 1
291034221
The expected value of at the end of the procedure is approximately , and when represented modulo .
Sample Input 2
720357616
Sample Output 2
153778832