import numpy as np INF = 100001 def solve(): n, q = map(int, input().split()) A = np.asarray([INF] + 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 = [n, -1, 0] for a, b, m in M: if l <= a and b <= r: if A[x[-1]] > A[m]: x[-1] = m x[0] = min(x[0], a) x[1] = max(x[1], b) if x[1] != -1: 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()