import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random #sys.setrecursionlimit(10**9) #sys.set_int_max_str_digits(0) #input = sys.stdin.readline #n = int(input()) # #alist = [] #https://github.com/shakayami/ACL-for-python/blob/master/segtree.py class segtree(): n=1 size=1 log=2 d=[0] op=None e=10**15 def __init__(self,V,OP,E): self.n=len(V) self.op=OP self.e=E self.log=(self.n-1).bit_length() self.size=1<>i) def get(self,p): assert 0<=p and p>=1 r>>=1 return self.op(sml,smr) def all_prod(self): return self.d[1] def max_right(self,l,f): assert 0<=l and l<=self.n assert f(self.e) if l==self.n: return self.n l+=self.size sm=self.e while(1): while(l%2==0): l>>=1 if not(f(self.op(sm,self.d[l]))): while(l1 and (r%2)): r>>=1 if not(f(self.op(self.d[r],sm))): while(r= 1: return 0 else: return 1 y = st.max_right(0,f) y = st.min_left(y,g) print(b[y]) elif t[0] == 2: for k,x,y in lazy: st.set(d[y],st.get(d[y])-1) st.set(d[x],st.get(d[x])+1) lazy.clear() check.clear() elif t[0] == 1: t,k,x = t lazy.append((k-1,x,a[k-1])) a[k-1] = x check.add(k-1)