#SGM0000027. Cây đoạn (Segment Tree)
Cây đoạn (Segment Tree)
Segment Tree
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
You are given an array . Process queries:
1 X V: set .2 L R: print .3 X V: find the smallest index such that and . If no such index exists, print .
Input
The first line contains .
The second line contains .
The next lines contain the queries.
Output
Print the answer for every query of type 2 or 3.
Subtasks
- Subtask 1 — 20%: .
- Subtask 2 — 30%: .
- Subtask 3 — 50%: , .
Examples
Input
5 5
1 2 3 2 1
2 1 5
3 2 3
1 3 1
2 2 4
3 1 3
Output
3
3
2
6
Explanation
The sample is processed in order; every printed item/line corresponds to an operation that requires output.