class RMQ: def __init__(self, N,INF=2**31-1): self.N0 = 2**(N-1).bit_length() self.INF=INF self.data = [INF]*(2*self.N0) def update(self, k, x): k += self.N0-1 self.data[k] = x while k >= 0: k = (k - 1) // 2 self.data[k] = min(self.data[2*k+1], self.data[2*k+2]) def query(self, l, r): L = l + self.N0; R = r + self.N0 s = self.INF while L < R: if R & 1: R -= 1 s = min(s, self.data[R-1]) if L & 1: s = min(s, self.data[L-1]) L += 1 L >>= 1; R >>= 1 return s N,Q=map(int,input().split()) *A,=map(int,input().split()) rmq = RMQ(N+1) indices = dict() for i in range(N): a = A[i] rmq.update(i+1,a) indices[a] = i+1 for i in range(Q): n,l,r=map(int,input().split()) if n == 1: a = rmq.query(l,l+1) b = rmq.query(r,r+1) rmq.update(l,b) rmq.update(r,a) indices[b] = l indices[a] = r else: MIN = rmq.query(l,r+1) idx = indices[MIN] print(idx)