output_description: For each query with T_i=2, 3, print the answer.
  
  * * *
input_description: 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
attempt: mycode = r"""
  # distutils: language=c++
  # cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True
  ctypedef long long LL
  # cython: cdivision=True
  from libc.stdio cimport scanf
  from libcpp.vector cimport vector
  ctypedef vector[LL] vec
  
  cdef class SegmentTree():
      cdef LL num,n
      cdef vec tree
  
      def __init__(self,vec A):
          cdef LL n,i
          n = A.size()
          self.n = n
          self.num = 1 << (n-1).bit_length()
          self.tree = vec(2*self.num,0)
          for i in range(n):
              self.tree[self.num + i] = A[i]
          for i in range(self.num-1,0,-1):
              self.tree[i] = max(self.tree[2*i],self.tree[2*i+1])
  
      cdef void update(self,LL k,LL x):
          k += self.num
          self.tree[k] = x
          while k>1:
              self.tree[k>>1] = max(self.tree[k],self.tree[k^1])
              k >>= 1
  
      cdef LL query(self,LL l,LL r):
          cdef LL res
          res = 0
          l += self.num
          r += self.num
          while l<r:
              if l&1:
                  res = max(res,self.tree[l])
                  l += 1
              if r&1:
                  res = max(res,self.tree[r-1])
              l >>= 1
              r >>= 1
          return res
  
      cdef LL bisect_l(self,LL l,LL r,LL x):
          cdef LL Lmin,Rmin,pos
          l += self.num
          r += self.num
          Lmin = -1
          Rmin = -1
          while l<r:
              if l&1:
                  if self.tree[l] >= x and Lmin == -1:
                      Lmin = l
                  l += 1
              if r&1:
                  if self.tree[r] >= x:
                      Rmin = r
              l >>= 1
              r >>= 1
  
          if Lmin!=-1:
              pos = Lmin
              while pos<self.num:
                  if self.tree[2*pos] >= x:
                      pos = 2*pos
                  else:
                      pos = 2*pos + 1
              return pos-self.num
  
          elif Rmin!=-1:
              pos = Rmin
              while pos<self.num:
                  if self.tree[2*pos] >= x:
                      pos = 2*pos
                  else:
                      pos = 2*pos + 1
              return pos-self.num
  
          else:
              return self.n
  
  
  cdef LL N,Q,i
  cdef vec A
  
  scanf("%lld %lld",&N,&Q)
  A = vec(N,-1)
  for i in range(N):
      scanf("%lld",&A[i])
  
  cdef SegmentTree S = SegmentTree(A)
  cdef LL t,x,v
  
  for i in range(Q):
      scanf("%lld %lld %lld",&t,&x,&v)
      if t==1:
          S.update(x-1,v)
      elif t==2:
          print(S.query(x-1,v))
      else:
          print(S.bisect_l(x-1,N,v)+1)
  """
  import sys
  import os
  
  if sys.argv[-1] == "ONLINE_JUDGE":  # コンパイル時
      with open("mycode.pyx", "w") as f:
          f.write(mycode)
      os.system("cythonize -i -3 -b mycode.pyx")
  
  import mycode
  
problem_description: Statement
  
  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.
samples: [{"input": "5 5\n    1 2 3 2 1\n    2 1 5\n    3 2 3\n    1 3 1\n    2 2 4\n    3 1 3", "output": "3\n    3\n    2\n    6\n    \n\n  * First query: Print 3, which is the maximum of (A_1,A_2,A_3,A_4,A_5)=(1,2,3,2,1).\n  * Second query: Since 3>A_2, j=2 does not satisfy the condition\uff0eSince 3 \\leq A_3, print j=3.\n  * Third query: Replace the value of A_3 with 1. It becomes A=(1,2,1,2,1).\n  * Fourth query: Print 2, which is the maximum of (A_2,A_3,A_4)=(2,1,2).\n  * Fifth query: Since there is no j that satisfies the condition, print j=N+1=6."}]