#C12010. Animal Strength Queries

    ID: 41391 Type: Default 1000ms 256MiB

Animal Strength Queries

Animal Strength Queries

You are given a list of n animals, each with a certain strength, and you need to process q queries. There are three types of queries:

  • Query Type 1: "1 l r" — Print the maximum strength among animals indexed from l to r (1-indexed).
  • Query Type 2: "2 x y" — Print the smallest (1-indexed) index within the range [x, y] where the animal has the maximum strength in that range.
  • Query Type 3: "3" — Print two space-separated integers: the minimum strength and the maximum strength across all animals.

Your task is to read the input from standard input and output the answer for each query on a separate line. For Query Type 3, output the two corresponding numbers separated by a space.

Note: The indices provided in the queries are 1-indexed.

inputFormat

The first line contains two integers n and q, denoting the number of animals and the number of queries respectively.

The second line contains n integers, where the i-th integer represents the strength of the i-th animal.

The following q lines each contain a query in one of the three formats described above.

outputFormat

For each query, print the result in a separate line. For queries of type 1 and 2, output a single integer. For queries of type 3, output two space-separated integers representing the minimum and maximum strength among all animals.

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

3 9 3 2 9 9

</p>