import math import sys def input(): return sys.stdin.readline().rstrip('\n') class SegTree: def __init__(self, n): self.n = 1 while self.n < n: self.n *= 2 self.idx = [(float('inf'), float('inf'))]*(2*self.n) def set(self, i, x): i += self.n self.idx[i] = x while i > 1: i //= 2 self.idx[i] = min(self.idx[2*i], self.idx[2*i+1]) def get(self, l, r): l += self.n r += self.n ans = (float('inf'), float('inf')) while l < r: if l % 2 == 1: ans = min(ans, self.idx[l]) l += 1 if r % 2 == 1: r -= 1 ans = min(ans, self.idx[r]) l //= 2 r //= 2 return ans def main(): n, q = map(int, input().split()) *a, = map(int, input().split()) seg = SegTree(n) for i in range(n): seg.set(i, (a[i], i)) for _ in range(q): t, l, r = map(int, input().split()) l -= 1 r -= 1 if t == 1: a[l], a[r] = a[r], a[l] seg.set(l, (a[l], l)) seg.set(r, (a[r], r)) else: print(seg.get(l, r+1)[1]+1) if __name__ == '__main__': main()