#include #include using namespace std; using namespace atcoder; using P = pair; P op(P a, P b) { return (a.first < b.first ? a : b); } P e() { return {2000000000, -1}; } int main() { int n, q; cin >> n >> q; segtree seg(n); for (int i = 0; i < n; i++) { int a; cin >> a; seg.set(i, {a, i + 1}); } while (q--) { int t, l, r; cin >> t >> l >> r; l--; r--; if (t == 1) { auto [lv, li] = seg.get(l); auto [rv, ri] = seg.get(r); seg.set(l, {rv, l + 1}); seg.set(r, {lv, r + 1}); } else { cout << seg.prod(l, r + 1).second << endl; } } }