#include using namespace std; // 1-indexed template struct SegmentTree { // a,b,c: T, e:T(unit) // abc = (ab)c = a(bc) // ae = ea = a typedef function F; int n; F f; T unit; vector dat; SegmentTree(){}; SegmentTree(int newn, F f, T t) : f(f), unit(t) { init(newn); } void init(int newn) { n = 1; while(n < newn) n <<= 1; dat.assign(n << 1, unit); } // "go up" process void update(int k, T newdata) { dat[k += n] = newdata; while(k >>= 1) { dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]); } } // [a,b) T query(int a, int b) { T vl = unit, vr = unit; for(int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) { if(l & 1) vl = f(vl, dat[l++]); if(r & 1) vr = f(dat[--r], vr); } return f(vl, vr); } }; int n, q; SegmentTree> seg; int main() { auto f = [](pair l, pair r) { return min(l, r); }; cin >> n >> q; seg = SegmentTree>(n, f, {n + 1, n + 1}); for(int i = 0; i < n; ++i) { int a; cin >> a; seg.update(i, {a, i}); } for(int i = 0; i < q; ++i) { int c, l, r; cin >> c >> l >> r; if(c == 1) { pair nl = seg.query(l - 1, l), nr = seg.query(r - 1, r); seg.update(l - 1, {nr.first, l - 1}); seg.update(r - 1, {nl.first, r - 1}); } else cout << seg.query(l - 1, r).second + 1 << endl; } return 0; }