#SGM0000017. Gán điểm và hợp thành hàm trên đoạn (Point Set Range Composite)
Gán điểm và hợp thành hàm trên đoạn (Point Set Range Composite)
Point Set Range Composite
Source: Library Checker
Version: Phuoc Hung OJ Extended
You are given affine functions in order:
Process queries:
0 p c d: replace by .1 l r x: compute
Indices are zero-based and the query range is half-open: .
Input
The first line contains .
The next lines contain .
The next lines describe the queries.
Output
For every type 1 query, print the composed function evaluated at modulo .
Subtasks
- Subtask 1 — 20%: .
- Subtask 2 — 30%: .
- Subtask 3 — 50%: .
Every coefficient and query value is in .
Examples
Input
3 4
2 1
3 4
1 5
1 0 3 1
0 1 1 0
1 0 3 1
1 1 3 2
Output
18
8
7
Explanation
The sample follows the operations exactly; each printed line corresponds to a query that requires output.