#include #define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i)) #define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i)) #define rep(i, n) For((i), 0, (n)) #define rrep(i, n) rFor((i), (n), 0) #define fi first #define se second using namespace std; typedef long long lint; typedef pair pii; typedef pair pil; typedef complex xy_t; const lint mod = 1e9 + 7; template struct SegTree{ typedef function F; int n = 1; vector node; T et; F f, g; SegTree(int n_, T et_, F f_, F g_): et(et_), f(f_), g(g_){ while(n < n_) n *= 2; node.resize(n*2-1, et); } void update(int i, T x){ i += n-1; node[i] = g(node[i], x); while(i){ i = (i-1) / 2; node[i] = f(node[i*2+1], node[i*2+2]); } } T query(int a, int b){ T vl = et, vr = et; for(a+=n-1, b+=n-1; a st(n, pii(100010, -1), f, g); rep(i, n){ int a; scanf("%d", &a); st.update(i, pii(a, i)); } while(q--){ int c, l, r; scanf("%d%d%d", &c, &l, &r); --l; --r; if(c == 1) { int vl = st.node[l+st.n-1].fi; int vr = st.node[r+st.n-1].fi; st.update(l, pii(vr, l)); st.update(r, pii(vl, r)); } else printf("%d\n", st.query(l, r+1).se+1); } }