Given an array of size
, support the
of the following operations:
- Find the value and index of the smallest element from index
to index
. If there are multiple smallest elements, find the index of the earliest one.
- Update the element at index
to value
.
Constraints
Input Specification
The first line contains integers
and
.
The second line contains integers
, the initial elements of
.
The next lines are one of two forms:
M l r
representing the first operation.U i x
representing the second operation.
Output Specification
For each type operation output two integers, the minimum value and the leftmost index of that value in the given range.
Sample Input
5 5
6 3 3 2 4
M 2 4
M 2 3
U 2 6
M 1 2
M 1 3
Sample Output
2 4
3 2
6 1
3 3
Comments