#K81632. Sequence Processor

    ID: 35797 Type: Default 1000ms 256MiB

Sequence Processor

Sequence Processor

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

  • Type 1: Update Query - Given an index i and a value x, update the ith element of the sequence to x.
  • Type 2: Range Query - Given two indices l and r, find the minimum and maximum values in the subrange of the sequence from index l to index r (inclusive). Formally, if the subrange is denoted by \( A[l, r] \), you need to output \( \min A[l, r] \) and \( \max A[l, r] \).

The sequence uses 1-indexed positions. Process all queries in the given order. For every query of type 2, output the result as two space-separated integers on a separate line.

Note: All updates affect subsequent queries.

inputFormat

The input is given from the standard input (stdin) with the following format:

  1. The first line contains two integers n and q separated by a space, representing the number of elements in the sequence and the number of queries.
  2. The second line contains n space-separated integers, representing the initial sequence.
  3. The following q lines each contain a query in one of the following formats:
    • For an update query: 1 i x where i is the index to update and x is the new value.
    • For a range query: 2 l r where l and r define the query range.

outputFormat

For each query of type 2, output a line with two space-separated integers representing the minimum and maximum values in the specified subrange. The output should be printed to the standard output (stdout).

## sample
8 5
2 7 -1 4 3 9 -2 5
2 2 6
1 3 10
2 1 4
1 5 -4
2 4 8
-1 9

2 10 -4 9

</p>