#SGM0000054. Truy vấn hai dãy (Two Sequence Queries)
Truy vấn hai dãy (Two Sequence Queries)
Two Sequence Queries
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Range-add either sequence or , and query on a range modulo .
Input
The first line contains . The next two lines contain sequences and . Each of the next lines is one of 1 l r x, 2 l r x, or 3 l r.
Output
For each type-3 query print the answer modulo .
Subtasks
-
Subtask 1 (20%): size and operation count at most 30; all other validity conditions are unchanged.
-
Subtask 2 (30%): size and operation count at most 3000; all other validity conditions are unchanged.
-
Subtask 3 (50%): full constraints:
-
-
-
Examples
Input
3 5
1 2 3
4 5 6
3 1 3
1 1 2 10
3 1 2
2 2 3 2
3 1 3
Output
32
104
152
Explanation
Initially . After adding 10 to , query [1,2] gives 104. After adding 2 to , the full-range sum is 152.