#0-indexed , 半開区間[a,b) #calc変更で演算変更 class SegTree: def __init__(self,N,first): self.NO = 2**(N-1).bit_length() self.First = first self.data = [first] * (2*self.NO) def calc(self,l,r): return min(l,r) def update(self,ind,x): ind += self.NO - 1 self.data[ind] = x while ind >= 0: ind = (ind - 1)//2 self.data[ind] = self.calc(self.data[2*ind+1],self.data[2*ind+2]) def query(self,l,r): L = l + self.NO R = r + self.NO s = self.First while L < R: if R & 1: R -= 1 s = self.calc(s , self.data[R-1]) if L & 1: s = self.calc(s , self.data[L-1]) L += 1 L >>= 1 R >>= 1 return s from sys import stdin N,Q = map(int,stdin.readline().split()) a = list(map(int,stdin.readline().split())) T = SegTree(N,(float("inf"),-1)) for i in range(N): T.update(i,(a[i],i)) for i in range(Q): s,l,r = map(int,stdin.readline().split()) l -= 1 r -= 1 if s == 1: a[l],a[r] = a[r],a[l] T.update(l,(a[l],l)) T.update(r,(a[r],r)) else: print(T.query(l,r+1)[1] + 1)