from collections import deque import numpy as np def solve(): n, q = map(int, input().split()) A = np.asarray([0] + list(map(int, input().split()))) M = [] flg = True for _ in range(q): c, l, r = map(int, input().split()) if c == 1: A[l], A[r] = A[r], A[l] flg = False else: if flg: x = [0, 0, 0, 0] for a, b, m in M: if b < l or r < a: continue t = min(b, r) - max(a, l) if x[0] < t: x = [t, a, b, m] if x[0] != 0: t, a, b, m = x l2 = l + np.argmin(A[l:a]) r2 = b + np.argmin(A[b:r + 1]) z = min([A[l2], l2], [A[r2], r2], [A[m], m]) M.append([l, r, z[1]]) print(z[1]) else: m = l + np.argmin(A[l:r + 1]) M.append([l, r, m]) print(m) else: flg = True m = l + np.argmin(A[l:r + 1]) M = [[l, r, m]] print(m) solve()