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 def binary_search2(func, n_min, n_max): left,right=n_min,n_max y_left, y_right = func(left), func(right) while right-left>1: middle = (left+right)//2 y_middle = func(middle) if y_left==y_middle: left=middle else: right=middle return left def index_search(idx): return rmq.query(idx,idx+1)==MIN N,Q=map(int,input().split()) *A,=map(int,input().split()) rmq = RMQ(N+1) for i in range(N): a = A[i] rmq.update(i+1,a) 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) else: MIN = rmq.query(l,r+1) idx = binary_search2(index_search,l,r+1)+1 print(idx)