import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int n = Integer.parseInt(sa[0]); int q = Integer.parseInt(sa[1]); sa = br.readLine().split(" "); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = Integer.parseInt(sa[i]); } SegmentTree st = new SegmentTree(n); st.init(a); PrintWriter pw = new PrintWriter(System.out); for (int i = 0; i < q; i++) { sa = br.readLine().split(" "); int p = Integer.parseInt(sa[0]); int l = Integer.parseInt(sa[1]) - 1; int r = Integer.parseInt(sa[2]); if (p == 1) { r--; st.update(l, r); } else { pw.println(st.query(l, r, 0, 0, n).i + 1); } } pw.flush(); } static class SegmentTree { int n = 2; int n2; Obj[] arr; Obj INF = new Obj(-1, Integer.MAX_VALUE); public SegmentTree(int x) { while (n < x) { n <<= 1; } n2 = n * 2 - 1; arr = new Obj[n2]; } void init(int[] a) { for (int i = 0; i < a.length; i++) { arr[i + n - 1] = new Obj(i, a[i]); } for (int i = a.length + n - 1; i < n2; i++) { arr[i] = INF; } for (int i = n - 2; i >= 0; i--) { if (arr[i * 2 + 1].a < arr[i * 2 + 2].a) { arr[i] = arr[i * 2 + 1]; } else { arr[i] = arr[i * 2 + 2]; } } } void update(int l, int r) { l += n - 1; r += n - 1; int a = arr[l].a; arr[l].a = arr[r].a; arr[r].a = a; update2(l); update2(r); } void update2(int i) { while (i > 0) { i = (i - 1) / 2; if (arr[i * 2 + 1].a < arr[i * 2 + 2].a) { arr[i] = arr[i * 2 + 1]; } else { arr[i] = arr[i * 2 + 2]; } } } Obj query(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return INF; // 交差しない if (a <= l && r <= b) return arr[k]; // 完全に含む Obj o1 = query(a, b, k * 2 + 1, l, (l + r) / 2); Obj o2 = query(a, b, k * 2 + 2, (l + r) / 2, r); if (o1.a < o2.a) { return o1; } return o2; } static class Obj { int i, a; public Obj(int i, int a) { this.i = i; this.a = a; } } } }