#K3951. Array Operations and Queries

    ID: 26436 Type: Default 1000ms 256MiB

Array Operations and Queries

Array Operations and Queries

You are given an array and a series of operations to perform on it. There are three types of operations:

  • SET i x: Update the element at index i of the array to x.
  • SUM L R: Compute the sum of elements in the subarray from index L to R (inclusive).
  • MUL L R: Compute the product of elements in the subarray from index L to R (inclusive). The result must be taken modulo \(10^9+7\).

Note that array indices are 1-indexed. Only the SUM and MUL operations produce output. If an operation is a SET, no output is produced.

The modulo is defined as \(MOD = 10^9+7\).

inputFormat

The first line contains two integers \(n\) and \(q\), where \(n\) is the length of the array and \(q\) is the number of operations.

The second line contains \(n\) space-separated integers representing the initial array.

The following \(q\) lines each contain an operation in one of the following formats: SET i x, SUM L R, or MUL L R.

outputFormat

For each operation of type SUM or MUL, output the result in the order the operations are given. Each result should be printed on a new line.

## sample
5 6
1 2 3 4 5
SUM 1 3
MUL 2 4
SET 3 10
SUM 1 3
MUL 2 4
SUM 1 5
6

24 13 80 22

</p>