#include #include #include #include #include #include #include #include #include #include #include #include #include #define vll vector #define vvvl vector #define vvl vector> #define VV(a, b, c, d) vector>(a, vector(b, c)) #define VVV(a, b, c, d) vector(a, vvl(b, vll (c, d))); #define re(c, b) for(ll c=0;c ar; struct segtree{ ll M=1, INF = 1000000000000000000, INIT; vector dat; segtree(ll N, ll num){ INIT = num; while(M0) { k = (k-1)/2; dat[k] = min(dat[k*2+1], dat[k*2+2]); } } ar query(ll a, ll b=-1, ll k=0, ll l=0, ll r=-1){ if(r==-1) r = M; if(b==-1) b = M; if(r<=a || b<=l) return ar{INIT, -INIT}; if(a<=l && r<=b) return dat[k]; ar A = query(a, b, k*2+1, l, (l+r)/2); ar B = query(a, b, k*2+2, (l+r)/2, r); return min(A, B); } }; int main() { ll n, q;std::cin >> n >> q; vll a(n);get(a); segtree seg(n, 10000000000); re(i, n) seg.update(a[i], i); re(i, q){ ll x, y, z;scanf("%lld %lld %lld", &x,&y,&z); y--, z--; if(x==1){ seg.update(a[y], z); seg.update(a[z], y); swap(a[y], a[z]); }else{ ar p = seg.query(y, z+1); std::cout << p[1] + 1 << '\n'; } } }