#SGM0000002. Truy vấn giá trị nhỏ nhất động (Dynamic Range Minimum Queries)

Truy vấn giá trị nhỏ nhất động (Dynamic Range Minimum Queries)

Dynamic Range Minimum Queries

Source: CSES

Version: Phuoc Hung OJ Extended

Problem Statement

You are given an array of nn integers and qq operations. Each operation either assigns a new value to one position or asks for the minimum value on a contiguous range.

Input

  • The first line contains two integers nn and qq.
  • The second line contains nn integers x1,x2,…,xnx_1,x_2,\ldots,x_n.
  • Each of the next qq lines is either 1 k u, which sets xk=ux_k=u, or 2 a b, which asks for the minimum among xa,xa+1,…,xbx_a,x_{a+1},\ldots,x_b.

Output

For every operation of type 2, print the requested minimum value on its own line.

Subtasks

  • Subtask 1 — 20%: 1≤n,q≤10001 \le n,q \le 1000, 1≤xi,u≤1061 \le x_i,u \le 10^6.
  • Subtask 2 — 30%: 1≤n,q≤500001 \le n,q \le 50000, 1≤xi,u≤1091 \le x_i,u \le 10^9.
  • Subtask 3 — 50%: 1≤n,q≤2⋅1051 \le n,q \le 2\cdot10^5, 1≤xi,u≤1091 \le x_i,u \le 10^9.

Examples

Input

8 4
3 2 4 5 1 1 5 3
2 1 4
2 5 6
1 2 3
2 1 4

Output

2
1
3

Explanation

Initially, the minimum on [1,4][1,4] is 22, and on [5,6][5,6] it is 11. After 1 2 3, the range [1,4][1,4] becomes 3,3,4,53,3,4,5, so its minimum is 33.