inf = 2**31-1 N, Q = map(int,input().split()) A = list(map(int,input().split())) queries = [[int(e)-1 for e in input().split()] for _ in range(Q)] class SegmentTree: def __init__(self, N): self.N = 2**(N-1).bit_length() self.data = [[inf, -1] for _ in range(2*self.N)] def update(self, k, x): self.data[k+N-1] = [x, k] k += self.N-1 while k >= 0: k = (k - 1) // 2 if self.data[2*k+1][0] < self.data[2*k+2][0]: self.data[k] = self.data[2*k+1][:] else: self.data[k] = self.data[2*k+2][:] def query(self, l, r): L = l + self.N R = r + self.N s = [inf, -1] while L < R: if R & 1: R -= 1 if s[0] > self.data[R-1][0]: s = self.data[R-1] if L & 1: if s[0] > self.data[L-1][0]: s = self.data[L-1] L += 1 L >>= 1; R >>= 1 return s st = SegmentTree(N) for i, a in enumerate(A): st.update(i, a) def solve(q, l, r): if q == 0: al, li = st.query(l, l+1) ar, ri = st.query(r, r+1) st.update(l, ar) st.update(r, al) elif q == 1: m, i = st.query(l,r+1) print(i+1) for q, l, r in queries: solve(q, l, r)