#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 decode(__int128_t a){ ll B = a%th; a -= B; return make_pair((a-th*th)/th, B); } struct segtree{ __int128_t M=1, INIT; __int128_t INF = encode(th, th); vector<__int128_t> 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]); } } __int128_t 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 INF; if(a<=l && r<=b) return dat[k]; __int128_t A = query(a, b, k*2+1, l, (l+r)/2); __int128_t 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, 0); 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{ pair p = decode(seg.query(y, z+1)); std::cout << p.second + 1 << '\n'; } } }