eolymp
bolt
Try our new interface for solving problems
Problems

Dot Product

Dot Product

You have two arrays A and B of the same length. You must process three kinds of queries.

  • * l r x: add an integer x to all Ai where lir.
  • . l r x: add an integer x to all Bi where lir.
  • ? l r: calculate the sum Al · Bl + ... + Ar · Br.

Arrays are 1-indexed. Initially, both arrays are filled with zeroes.

Input

The first line contains two space-separated integers n and m: the arrays' lengths and the number of queries, respectively (1n, m105). The next m lines contain queries in the format described above. In each query 1lrn and 1x < 109 + 7.

Output

For each query of the third type, print its result modulo 109 + 7 on a separate line.

Time limit 2 seconds
Memory limit 256 MiB
Input example #1
5 4
* 1 4 10
. 2 5 8
? 1 3
? 2 5
Output example #1
160
240
Source 2013 Petrozavodsk, MIPT contest, August 25, Problem K