Problem10270--CF EDU - Segment Tree P1 - Step 2 - D. First element at least X - 2

10270: CF EDU - Segment Tree P1 - Step 2 - D. First element at least X - 2

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

In this task, you need to add to the segment tree the operation of finding for the given $x$ and $l$ the minimum index $j$ such that $j≥l$ and $a[j]≥x$.

Input

The first line contains two integers $n,m\ (1≤n,m≤100,000)$, the size of the array and the number of operations. 
The next line contains $n$ numbers $a_i$, the initial state of the array $(0≤a_i≤10^9)$. 
The following lines contain the description of the operations. The description of each operation is as follows:
  • $\text{1 i v}$: change the item with index $i$ to $v\ (0≤i<n,\ 0≤v≤10^9)$.
  • $\text{2 x l}$: find the minimum index $j$ such that $j≥l$ and $a[j]≥x\ (0≤x≤10^9,\ 0≤l<n)$. If there is no such element, print −1. Indices start from 0.

Output

For each operation of the second type, print the answer for the query.

Sample 1 Input

5 7
1 3 2 4 3
2 3 0
2 3 2
1 2 5
2 4 1
2 5 4
1 3 7
2 6 1

Sample 1 Output

1
3
2
-1
3

HINT

CF EDU.

Source/Category