#include using namespace std; struct Segt { vector> minvi; Segt(vector a) { minvi.resize(a.size() << 2); function build = [&](int t, int lb, int rb) { if (rb - lb == 1) return void(minvi[t] = make_pair(a[lb], lb)); int mb = lb + rb >> 1; build(t << 1, lb, mb); build(t << 1 | 1, mb, rb); minvi[t] = min(minvi[t << 1], minvi[t << 1 | 1]); }; build(1, 0, a.size()); } void update(int t, int lb, int rb, int k, int v) { if (rb - lb == 1) return void(minvi[t] = make_pair(v, k)); int mb = lb + rb >> 1; if (k < mb) update(t << 1, lb, mb, k, v); else update(t << 1 | 1, mb, rb, k, v); minvi[t] = min(minvi[t << 1], minvi[t << 1 | 1]); } pair query(int t, int lb, int rb, int ql, int qr) { if (qr <= lb || rb <= ql) return make_pair(0x3f3f3f3f, -1); if (ql <= lb && rb <= qr) return minvi[t]; int mb = lb + rb >> 1; return min(query(t << 1, lb, mb, ql, qr), query(t << 1 | 1, mb, rb, ql, qr)); } }; int main() { ios::sync_with_stdio(false); int N, Q; cin >> N >> Q; vector A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } Segt tree(A); for (int i = 0; i < Q; ++i) { int P, L, R; cin >> P >> L >> R; --L; if (P == 1) { int u = tree.query(1, 0, N, L, L + 1).first; int v = tree.query(1, 0, N, R - 1, R).first; tree.update(1, 0, N, L, v); tree.update(1, 0, N, R - 1, u); } else { cout << tree.query(1, 0, N, L, R).second + 1 << "\n"; } } return 0; }