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: from copy import copy
  
  
  class Seg_Tree:
      def __init__(self, init_list, init_value, func=min):
          il_len = len(init_list)
          r = 1
          while il_len > r:
              r *= 2
          self.tree = (
              [0 for i in range(r - 1)]
              + copy(init_list)
              + [init_value for i in range(r - il_len)]
          )
          self.func = func
          self.len = r
          self.init_value = init_value
          for i in range(r - 2, -1, -1):
              self.tree[i] = self.func(self.tree[i * 2 + 1], self.tree[i * 2 + 2])
  
      def update(self, x, value):
          x += self.len - 1
          self.tree[x] = value
          x = (x - 1) // 2
          while x >= 0:
              self.tree[x] = self.func(self.tree[x * 2 + 1], self.tree[x * 2 + 2])
              x = (x - 1) // 2
  
      def query(self, l, r, x=0):
          xl = x
          xr = x
          while xl < r - 1:
              xl, xr = xl * 2 + 1, xr * 2 + 2
          if xr < l or r < xl:
              return self.init_value
          elif l <= xl and xr <= r:
              return self.tree[x]
          else:
              return self.func(self.query(l, r, x * 2 + 1), self.query(l, r, x * 2 + 2))
  
  
  n, q = map(int, input().split())
  a = list(map(int, input().split()))
  st = Seg_Tree(a, -1, max)
  
  for i in range(q):
      qu = list(map(int, input().split()))
      if qu[0] == 1:
          st.update(qu[1] - 1, qu[2])
      elif qu[0] == 2:
          print(st.query(qu[1] - 1, qu[2] - 1))
      else:
          l, r = qu[1] - 2, n
          while r - l != 1:
              t = (l + r) // 2
              v = st.query(qu[1] - 1, t)
              if v >= qu[2]:
                  r = t
              else:
                  l = t
          print(r + 1)
  
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."}]