n,q=map(int,input().split()) a=list(map(int,input().split())) B=317 st1=[(0,i) for i in range(B*B)] st2=[(0,0)]*B for i in range(n): st1[i]=(a[i],i) for i in range(B): st2[i]=min(st1[i*B:i*B+B]) for _ in range(q): t,l,r=map(int,input().split()) l-=1 r-=1 if t==1: st1[l],st1[r]=(st1[r][0],l),(st1[l][0],r) y=l//B st2[y]=min(st1[y*B:y*B+B]) y=r//B st2[y]=min(st1[y*B:y*B+B]) if t==2: a=(n,n) yl=l//B yr=r//B if yl==yr: for i in range(l,r+1): a=min(a,st1[i]) else: for i in range(l,yl*B+B): a=min(a,st1[i]) for i in range(yr*B,r+1): a=min(a,st1[i]) for i in range(yl+1,yr): a=min(a,st2[i]) print(a[1]+1)