10285: CF EDU - Segment Tree P2 - Step 2 - B. Multiplication and Sum
[Creator : ]
Description
There is an array of $n$ elements, initially filled with ones. You need to write a data structure that processes two types of queries:
- multiply all elements on the segment from $l$ to $r−1$ by number $v$,
- find the sum on the segment from $l$ to $r−1$.
Both operations are performed modulo $10^9+7$.
Input
The first line contains two numbers $n,m\ (1≤n,m≤100,000)$, the size of the array and the number of operations.
The following lines contain the desc
- 1 l r v: multiply all elements on the segment from $l$ to $r−1$ by number $v\ (0≤l<r≤n,\ 1≤v<10^9+7)$
- 2 l r: find the sum on the segment from $l$ to $r−1\ (0≤l<r≤n)$.
Output
For each operation of the second type, print the corresponding value.
Sample 1 Input
5 6
1 0 3 3
2 1 2
1 1 4 4
2 1 3
2 1 4
2 3 5
Sample 1 Output
3
24
28
5
Sample 2 Input
2 3
1 0 1 1000000
1 0 2 1000000
2 0 2
Sample 2 Output
993000