#include using namespace std; class SegTree { using T = pair; static const T& op(const T& lhs, const T& rhs) { // binary operator return min(lhs, rhs); } const int N; T *data; static int calc_size(int sz) { int n = 1; while (sz > n) n *= 2; return 2*n-1; } public: explicit SegTree(int sz) : N(calc_size(sz)) { data = new T[2*N-1]; } ~SegTree() { delete[] data; } T query(int a, int b, int i = -1, int l = -1, int r = -1) const { if (i == -1) { i = 0; l = 0; r = 2*N-1; } if (a <= l && r <= b) return data[i]; int m = (l+r)/2; if (b <= m) return query(a, b, 2*i+1, l, m); if (m <= a) return query(a, b, 2*i+2, m, r); T v1 = query(a, b, 2*i+1, l, m), v2 = query(a, b, 2*i+2, m, r); return op(v1, v2); } T get(int i) const { return data[i + N - 1]; } void update(int i, int v) { int x = i + N - 1; data[x] = {v, i}; while (x > 0) { x = (x-1)/2; data[x] = op(data[2*x+1], data[2*x+2]); } } }; int main() { int n, q; cin >> n >> q; SegTree st(n); for (int i = 0; i < n; i++) { int a; cin >> a; st.update(i, a); } while (q--) { int x, l, r; cin >> x >> l >> r; l--; r--; if (x == 1) { int al = st.get(l).first, ar = st.get(r).first; st.update(l, ar); st.update(r, al); } else { cout << st.query(l, r+1).second + 1 << endl; } } }