import copy #####segfunc###### def segfunc(x,y): res = x if x[0] < y[0] else y return res def init(init_val): #set_val for i in range(len(init_val)): seg[i+num-1]=init_val[i] #built for i in range(num-2,-1,-1) : seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) def update(k,x): k += num-1 seg[k] = x while k: k = (k-1)//2 seg[k] = segfunc(seg[k*2+1],seg[k*2+2]) def query(p,q): if q<=p: return ide_ele p += num-1 q += num-2 res=ide_ele while q-p>1: if p&1 == 0: res = segfunc(res,seg[p]) if q&1 == 1: res = segfunc(res,seg[q]) q -= 1 p = p//2 q = (q-1)//2 if p == q: res = segfunc(res,seg[p]) else: res = segfunc(segfunc(res,seg[p]),seg[q]) return res n , q = map(int, input().split()) a = list(map(int, input().split())) a = [[a[i], i+1] for i in range(n)] #####単位元###### ide_ele = [n+1,n+1] num =2**(n-1).bit_length() seg=[ide_ele]*(2*num - 1) init(a) #半開区間に注意 for i in range(q): x,l,r = map(int, input().split()) if x == 1: tmp = copy.deepcopy(seg[l+num-2]) tmp[1] = r tmp2 = seg[r+num-2] tmp2[1] = l update(l-1,tmp2) update(r-1,tmp) else: ans = query(l-1,r) print(ans[1])