Min Max Queries


You are given an array of nn integers and must process qq queries of the following types:

  1. Change the value at position kk to uu.
  2. Find the minimum and maximum values over the range [l,r][l, r].

Positions are 1-indexed.

Input

The first line contains the integer nn, the size of the array.

The second line contains nn space-separated integers x1,x2,,xnx_1, x_2, \ldots, x_n: the initial values of the array.

The third line contains the integer qq, the number of queries.

Each of the next qq lines describes a query and is one of the following:

  • 1 k u: set the value at position kk to uu
  • 2 l r: query the minimum and maximum values over the range [l,r][l, r]

Output

For each query of type 2, output a line containing the minimum and maximum of the given range, separated by a space.

Constraints

  • 1n1051 \le n \le 10^5
  • 1q1041 \le q \le 10^4
  • 109xi,u109-10^9 \le x_i, u \le 10^9
  • 1kn1 \le k \le n
  • 1lrn1 \le l \le r \le n

Example 1

Input 1
5
-2 0 10 -10 -7 
10
1 4 -2
2 4 5
2 4 5
2 1 3
1 5 6
1 2 -3
1 2 -5
1 5 -5
2 2 3
2 3 5
Output 1
-7 -2
-7 -2
-2 10
-5 10
-5 10

Example 2

Input 2
10
8 -6 -4 -3 4 2 7 10 -9 -7 
10
2 2 3
2 6 10
2 4 5
1 8 -5
2 7 10
2 5 8
2 2 10
1 9 6
2 3 5
2 9 10
Output 2
-6 -4
-9 10
-3 4
-9 7
-5 7
-9 7
-4 4
-7 6

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.