Deja Vu

배열에서 값을 바꾸는 갱신과 함께, 각 질의 l에 대해 l <= a < b < c < d이고 x_a < x_b < x_c < x_d인 가장 작은 d를 구하거나 없으면 -1을 출력한다.

어려움9세그먼트 트리동적 계획법이분 탐색구현아직 제출이 없습니다시간 제한5초메모리 제한512 MB

문제

You may be right that there are a lot (maybe even too many) problems of kind ``given array of length 10510^5 and 10510^5 queries of 10510^5 different types, do some...

- Um_nik

You are given an array x_1,x_2,,x_nx\_1, x\_2, \ldots, x\_n.

You need to perform two types of queries on this array.

  • Given ii and yy, set x_i=yx\_i = y.
  • Given ll, find the smallest dd among all tuples (a,b,c,d)(a,b,c,d) with la<b<c<dl \leq a < b < c < d and x_a<x_b<x_c<x_dx\_a < x\_b < x\_c < x\_d, or reply that there are no such tuples.

입력

The first line contains two integers n,qn,q (1n,q500,0001 \leq n,q \leq 500\\,000): the number of elements in the array and the number of queries.

The second line contains nn integers x_1,x_2,,x_nx\_1, x\_2, \ldots, x\_n (1x_i1091 \leq x\_i \leq 10^9).

Each of the next qq lines contains the description of a query.

If the first integer in the line is equal to 11, then the next two integers are ii and yy (1in1 \leq i \leq n, 1y1091 \leq y \leq 10^9), describing a query of the first type.

Otherwise, the first integer in the line is equal to 22, and the next integer is equal to ll (1ln1 \leq l \leq n), describing a query of the second type.

출력

For each query of the second type, return the smallest dd among all tuples (a,b,c,d)(a,b,c,d) such that la<b<c<dl \leq a < b < c < d and x_a<x_b<x_c<x_dx\_a < x\_b < x\_c < x\_d, or print "-1" if there are no such tuples.