#C10962. Sequence Query Processor

    ID: 40225 Type: Default 1000ms 256MiB

Sequence Query Processor

Sequence Query Processor

You are given a sequence of n integers and q queries. There are three types of queries:

  • Type 1: Update the value at index \(i\) to \(x\). The query is given as: 1 i x.
  • Type 2: Compute the sum of the elements from index \(l\) to \(r\) (inclusive). The query is given as: 2 l r.
  • Type 3: Compute the product of the elements from index \(l\) to \(r\) (inclusive). The query is given as: 3 l r.

Note that the array is 1-indexed. For update queries (type 1), no output is produced. For queries of type 2 and 3, print the result in the order the queries are given.

Input is taken from standard input (stdin) and output should be written to standard output (stdout).

inputFormat

The first line of the input contains two integers \(n\) and \(q\): the number of elements in the sequence and the number of queries, respectively.

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

The next \(q\) lines each contain a query in one of the following formats:

  • 1 i x — Update: assign \(x\) to \(\text{sequence}[i]\).
  • 2 l r — Sum Query: output the sum of elements from index \(l\) to \(r\).
  • 3 l r — Product Query: output the product of elements from index \(l\) to \(r\).

outputFormat

For each query of type 2 or type 3, output the result on a separate line in the order the queries are processed. If there are no queries that produce an output, print nothing.

## sample
5 6
1 2 3 4 5
2 1 3
3 2 4
1 3 10
2 1 3
3 2 4
2 1 5
6

24 13 80 22

</p>