Maintain an array under range add, range multiply, and range assign modulo 1e9+7, answering range sum queries.
You are given a sequence A1,A2,…,ANA_1, A_2, \dots, A_NA1,A2,…,AN of length NNN. Write a program that processes the following four kinds of queries.
1 x y v
2 x y v
3 x y v
4 x y
The modulus is always 109+710^9+7109+7, and mod \bmodmod is the remainder operation.
The first line contains the length NNN of the sequence. (1≤N≤1000001 \le N \le 1000001≤N≤100000)
The second line contains A1,A2,…,ANA_1, A_2, \dots, A_NA1,A2,…,AN. (1≤Ai≤1091 \le A_i \le 10^91≤Ai≤109)
The third line contains the number of queries MMM. (1≤M≤1000001 \le M \le 1000001≤M≤100000)
Each of the next MMM lines contains one query. (1≤x≤y≤N1 \le x \le y \le N1≤x≤y≤N, 1≤v≤1091 \le v \le 10^91≤v≤109)
For each query of type 4, print the answer on its own line, in the order the queries are given.