#arc111f. [arc111_f]Do you like query problems?
[arc111_f]Do you like query problems?
Problem Statement
Yosupo loves query problems. He made the following problem:
A Query Problem
We have an integer sequence of length : . Initially, . We also have a variable , which is initially . Here, you will be given queries of the following forms:
Type 1:
For each , .
Type 2:
For each , .
Type 3:
Compute and add the result to .
Print the final value of .
Here, for each query, holds. Additionally, for Type 1 and 2, holds.
Maroon saw this problem, thought it was too easy, and came up with the following problem:
Query Problems
Given are positive integers . There are valid inputs for "A Query Problem". Find the sum of outputs over all those inputs, modulo .
Find it.
Constraints
- All numbers in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
1 2 2
Sample Output 1
1
There are valid inputs, and just one of them - shown below - results in a positive value of .
$t_1 = 2, l_1 = 1, r_1 = 1, v_1 = 1, t_2 = 3, l_2 = 1, r_2 = 1$
will be in this case, so the answer is .
Sample Input 2
3 1 4
Sample Output 2
0
Sample Input 3
111 112 113
Sample Output 3
451848306