410094: GYM103940 K Krystalova's Trivial Problem

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

K. Krystalova's Trivial Problemtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Krystalova is writing trivial problems (as always) but now for some reason (lucky for you) she also wrote a trivial statement.

You have a trivial list of numbers $$$L$$$, and two trivial operations:

1. $$$u$$$ $$$l$$$ $$$r$$$ $$$x$$$: Add $$$x$$$ to the numbers in $$$L$$$ in the range $$$[l, r]$$$.

2. $$$q$$$ $$$l$$$ $$$r$$$: Get the sum of $$$L_i^2$$$ for every $$$i$$$ in the range $$$[l, r]$$$.

Input

In the first line of input two integers $$$N$$$ $$$(1 \leq N \leq 10^5)$$$, $$$Q$$$ $$$(1 \leq Q \leq 10^4)$$$, the size of $$$L$$$ and the number of operations respectively.

The next line contains $$$N$$$ integers $$$L_i$$$ $$$(0 \leq L_i \leq 10^8)$$$, the elements of $$$L$$$.

The next $$$Q$$$ lines contains an operation, that can be one of the two types described before. If the line starts with a letter "$$$u$$$" then will be three integers $$$l$$$ $$$(1 \leq l \leq N)$$$, $$$r$$$ $$$(1 \leq r \leq N)$$$, $$$x$$$ $$$(-10^8 \leq x \leq 10^8)$$$. If the line starts with a letter "$$$q$$$" then will be two integers $$$l$$$ $$$(1 \leq l \leq N)$$$, $$$r$$$ $$$(1 \leq r \leq N)$$$

Output

For every operation of type 2, print in one line the result of the operation. As the answer might be very large, please output the answer modulo $$$10^9 + 7$$$

ExampleInput
5 5
1 1 1 1 1
u 1 3 1
q 1 5
u 3 5 1
q 3 3
q 1 5
Output
14
9
25

加入题单

上一题 下一题 算法标签: