Problem: You are given an array a_0, a_1, ..., a_{N-1} of length N. Process Q queries of the following types.

The type of i-th query is represented by T_i.

* T_i=1: You are given two integers X_i,V_i. Replace the value of A_{X_i} with V_i.
* T_i=2: You are given two integers L_i,R_i. Calculate the maximum value among A_{L_i},A_{L_i+1},\cdots,A_{R_i}.
* T_i=3: You are given two integers X_i,V_i. Calculate the minimum j such that X_i \leq j \leq N, V_i \leq A_j. If there is no such j, answer j=N+1 instead.

Constraints

* 1 \leq N \leq 2 \times 10^5
* 0 \leq A_i \leq 10^9
* 1 \leq Q \leq 2 \times 10^5
* 1 \leq T_i \leq 3
* 1 \leq X_i \leq N, 0 \leq V_i \leq 10^9 (T_i=1,3)
* 1 \leq L_i \leq R_i \leq N (T_i=2)
* All values in Input are integer.

Input

Input is given from Standard Input in the following format:


N Q
A_1 A_2 \cdots A_N
First query
Second query
\vdots
Q-th query


Each query is given in the following format:

If T_i=1,3,


T_i X_i V_i


If T_i=2,


T_i L_i R_i


Output

For each query with T_i=2, 3, print the answer.

Example

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

Solution (in PYTHON3):

Solution:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


### セグメント木

class SegmentTree:
    def __init__(self, n, a=None):
        """初期化
        num : n以上の最小の2のべき乗
        """
        num = 1
        while num<=n:
            num *= 2
        self.num = num
        self.seg = [0] * (2*self.num-1)
        if a is not None:
            # O(n)で初期化
            assert len(a)==n
            for i in range(n):
                self.seg[num-1+i] = a[i]
            for k in range(num-2, -1, -1):
                self.seg[k] = max(self.seg[2*k+1], self.seg[2*k+2])
#             for i,item in enumerate(a):
#                 self.update(i,item)
    def update(self,i,x):
        """update(i,x):Aiをxに更新する
        """
        k = i+(self.num-1)
        self.seg[k] = x
        k = (k-1)//2
        while k >= 0:
            self.seg[k] = max(self.seg[2*k+1], self.seg[2*k+2])
            k = (k-1)//2
    # def query(self,l,r):
    #     """[l,r)の最大値
    #     """
    #     sml = smr = -float("inf")
    #     l += self.num
    #     r += self.num
    #     while l<r:
    #         if l&1:
    #             sml = max(sml, self.seg[l])
    #             l += 1
    #         if r&1:
    #             r -= 1
    #             smr = max(smr, self.seg[r])
    #         l >>= 1
    #         r >>= 1
    #     return max(sml,smr)
    def query(self,a,b):
        k = 0
        l = 0
        r = self.num
        q = [(k,l,r)]
        ans = -float("inf")
        while q:
            k,l,r = q.pop()
            if r<=a or b<=l:
                pass
            elif a<=l and r<=b:
                ans = max(ans, self.seg[k])
            else:
                q.append((2*k+1,l,(l+r)//2))
                q.append((2*k+2,(l+r)//2,r)) 
        return ans
    # def query(self,a,b):
    #     return self._query(a,b,0,0,self.num)
    # def _query(self,a,b,k=0,l=0,r=None):
    #     """query(a,b,0,0,num):[a,b)の最大値, [l,r): ノードkの表す区間
    #     """
    #     if r is None:
    #         r = self.num
    #     if r <= a or b <= l:
    #         return -float("inf")
    #     elif a <= l and r <= b:
    #         return self.seg[k]
    #     else:
    #         return max(self._query(a,b,2*k+1,l,(l+r)//2),self._query(a,b,2*k+2,(l+r)//2,r))
    def find_right(self,a,b,x):
        """[a,b)で値がx以上のインデックスの最大
        """
        return self._find_right(a,b,x,k=0,l=0,r=self.num)
    def _find_right(self,a,b,x,k,l,r):
        if self.seg[k]<x or r<=a or b<=l: # x以上を満たせない or 区間が重複しない
            return -1
        elif k>=self.num-1: # 自身が葉
            return k - (self.num-1)
        else:
            vr = self._find_right(a,b,x,2*k+2,(l+r)//2,r)
            if vr>=0:
                return vr
            else:
                return self._find_right(a,b,x,2*k+1,l,(l+r)//2)
    def find_left(self,a,b,x):
        """[a,b)で値がx以上のインデックスの最小
        """
        return self._find_left(a,b,x,k=0,l=0,r=self.num)
    def _find_left(self,a,b,x,k,l,r):
        if self.seg[k]<x or r<=a or b<=l: # x以上を満たせない or 区間が重複しない
            return self.num
        elif k>=self.num-1: # 自身が葉
            return k - (self.num-1)
        else:
            vl = self._find_left(a,b,x,2*k+1,l,(l+r)//2)
            if vl<self.num:
                return vl
            else:
                return self._find_left(a,b,x,2*k+2,(l+r)//2,r)
    def query_index(self,a,b,k=0,l=0,r=None):
        """query(a,b,0,0,num):[a,b)の最大値
        最大値を与えるインデックスも返す
        """
        if r is None:
            r = self.num
        if r <= a or b <= l:
            return (-float("inf"), None)
        elif a <= l and r <= b:
            return (self.seg[k], self._index(k))
        else:
            return max(self.query_index(a,b,2*k+1,l,(l+r)//2),self.query_index(a,b,2*k+2,(l+r)//2,r))
    def _index(self, k):
        if k>=self.num:
            return k - (self.num-1)
        else:
            if self.seg[2*k+1]>=self.seg[2*k+2]:
                return self._index(2*k+1)
            else:
                return self._index(2*k+2)
n,q = list(map(int, input().split()))
a = list(map(int, input().split()))
sg = SegmentTree(n, a)
for _ in range(q):
    t,x,y = map(int, input().split())
    if t==1:
        sg.update(x-1,y)
    elif t==2:
        print(sg.query(x-1,y))
    else:
        res = sg.find_left(x-1,n,y)+1
        if res>=n+1:
            print(n+1)
        else:
            print(res)