#K82087. Array Operation Processor

    ID: 35897 Type: Default 1000ms 256MiB

Array Operation Processor

Array Operation Processor

You are given an array of n integers and required to process m operations on the array. The operations are of two types:

  • Read Operation: Query the value at a given 1-based index.
  • Write Operation: Update the value at a given 1-based index to a new value.

For a read operation, output the value at the specified index. Note that the index conversion from 1-based to 0-based is given by the formula: \( index_{0} = index_{1} - 1 \).

This is a basic simulation problem where you have to update the array according to the operations and output the results of read operations.

inputFormat

The first line contains two integers n and m, representing the number of elements in the array and the number of operations, respectively.

The second line contains n space-separated integers denoting the initial array.

Each of the next m lines contains an operation in one of the following two formats:

  • 1 i: A read operation which prints the value at index i.
  • 2 i x: A write operation which updates the array element at index i to x.

Please note that the indices are 1-based. In other words, the actual position in your array is \( i-1 \) for an input index \( i \).

outputFormat

For each read operation, output the result on a separate line.

## sample
5 6
10 20 30 40 50
1 3
2 3 100
1 3
1 5
2 5 500
1 5
30

100 50 500

</p>