#SGM0000016. Truy vấn cửa hàng pizza (Pizzeria Queries)
Truy vấn cửa hàng pizza (Pizzeria Queries)
Pizzeria Queries
Source: CSES
Version: Phuoc Hung OJ Extended
There are buildings on a street, numbered through . Building has a pizzeria with base price . If you are in building and order from building , the total price is:
Process two query types:
1 k x: set the pizza price at building to .2 k: while at building , find the minimum total price.
Input
The first line contains .
The second line contains .
The next lines describe the queries.
Output
For every type 2 query, print the minimum price.
Subtasks
- Subtask 1 — 20%: , .
- Subtask 2 — 30%: , .
- Subtask 3 — 50%: , .
Examples
Input
6 3
8 6 4 5 7 5
2 2
1 5 1
2 2
Output
5
4
Explanation
The sample follows the operations exactly; each printed line corresponds to a query that requires output.