from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit import heapq as hq; import itertools as its; import operator as op # globals inf = float('inf') input = stdin.readline from math import ceil, log2 inf = float('inf') class SegmentTree: def __init__(self, lst, _min=min, _max=inf): self.n = int(2**ceil(log2(len(lst)))) self._lst = [_max for _ in range(2 * self.n - 1)] self.min = _min self.max = _max for i, v in enumerate(lst): self.update(i, v) @property def lst(self): return self._lst[self.n-1:] def update(self, i, v): i += self.n - 1 self._lst[i] = v while i > 0: i = (i - 1) // 2 self._lst[i] = self.min(self._lst[i*2+1], self._lst[i*2+2]) def query(self, a, b): return self._query(a, b, 0, 0, self.n) def _query(self, a, b, k, l, r): if r <= a or b <= l: return self.max if a <= l and r <= b: return self._lst[k] vl = self._query(a, b, k * 2 + 1, l, (l + r) // 2) vr = self._query(a, b, k * 2 + 2, (l + r) // 2, r) return self.min(vl, vr) def main(): n, q = get_li() a = get_li() b = list(enumerate(a)) st = SegmentTree(b, _min=lambda x, y: x if x[1] < y[1] else y, _max=(inf, inf)) for _ in range(q): t, l, r = get_li() if t == 1: vl = (r-1, st.lst[l-1][1]) vr = (l-1, st.lst[r-1][1]) st.update(l-1, vr) st.update(r-1, vl) elif t == 2: i, _ = st.query(l-1, r) print(i+1) return def get_int(): return int(input()) def get_float(): return float(input()) def get_str(): return input().strip() def get_li(): return [int(i) for i in input().split()] def get_lf(): return [float(f) for f in input().split()] def get_lc(): return list(input().strip()) def gets(n, types, sep=None): if len(types) == 1: return [types[0](input().strip()) for _ in range(n)] return list(zip(*( [t(x) for t, x in zip(types, input().strip().split(sep=sep))] for _ in range(n) ))) if __name__ == '__main__': setrecursionlimit(4100000) main()