N,M = map(int,input().split()) k = 0 while 2**k0: if T[2*i][0]<=T[2*i+1][0]: T[i] = T[2*i+1] else: T[i] = T[2*i] i //= 2 def find(l,r): # 区間最大値 l += K-1 # 左側の頂点 r += K-1 # 右側の頂点 res = [0,0] while lres[1]: res = T[l] l += 1 # 右隣の頂点に移る if r&1: # &0としたいところだが、この操作は意味ない r -= 1 # 左隣の頂点に移る if res[0]res[1]: res = T[r] l >>= 1 # 親に移る r >>= 1 # 親に移る return res for i in range(M): update(i+1,A[i]) Q = int(input()) for _ in range(Q): t,x,y = map(int,input().split()) if t==1: update(x,y) elif t==2: update(x,-y) else: print(find(1,M+1)[1])