#include using namespace std; using ll=long long; #define int ll #define rng(i,a,b) for(int i=int(a);i=int(a);i--) #define per(i,b) gnr(i,0,b) #define pb push_back #define eb emplace_back #define a first #define b second #define bg begin() #define ed end() #define all(x) x.bg,x.ed #ifdef LOCAL #define dmp(x) cerr<<__LINE__<<" "<<#x<<" "< void chmax(t&a,u b){if(a void chmin(t&a,u b){if(b using vc=vector; template using vvc=vc>; using pi=pair; using vi=vc; template ostream& operator<<(ostream& os,const pair& p){ return os<<"{"< ostream& operator<<(ostream& os,const vc& v){ os<<"{"; for(auto e:v)os< void print_tuple(ostream&,const T&){ } template void print_tuple(ostream&os,const T&t){ if(i)os<<","; os<(t); print_tuple(os,t); } template ostream& operator<<(ostream&os,const tuple&t){ os<<"{"; print_tuple<0,tuple,Args...>(os,t); return os<<"}"; } void print(ll x,int suc=1){ cout<>i; return i; } vi readvi(int n,int off=0){ vi v(n); rep(i,n)v[i]=read()+off; return v; } template void print(const vector&v,int suc=1){ rep(i,v.size()) print(v[i],i==int(v.size())-1?suc:2); } string readString(){ string s; cin>>s; return s; } template T sq(const T& t){ return t*t; } //#define CAPITAL void yes(bool ex=true){ #ifdef CAPITAL cout<<"YES"< void mkuni(vc&v){ sort(all(v)); v.erase(unique(all(v)),v.ed); } ll rand_int(ll l, ll r) { //[l, r] static random_device rd; static mt19937_64 gen(rd()); return uniform_int_distribution(l, r)(gen); } //CF Global3 H //point update template struct SegTree{ vc buf; int s; const F f; const T g; SegTree(const vc& d,F ff,T gg):f(ff),g(gg){ int n=d.size(); s=1; while(s>=1)u(i); } T get(int b,int e,int l,int r,int i){ if(e<=l||r<=b)return g; if(b<=l&&r<=e)return buf[i]; int m=(l+r)/2; return f(get(b,e,l,m,i*2),get(b,e,m,r,i*2+1)); } T get(int b,int e){ return get(b,e,0,s,1); } }; template SegTree segtree(const vc& d,F f,T g){ return SegTree(d,f,g); } signed main(){ cin.tie(0); ios::sync_with_stdio(0); cout<>n>>q; vc a(n); rep(i,n){ cin>>a[i].a; a[i].b=i+1; } auto seg=segtree(a,[](pi x,pi y){return min(x,y);},pi(inf,inf)); rep(_,q){ int t,l,r;cin>>t>>l>>r; l--; if(t==1){ r--; swap(a[l].a,a[r].a); seg.set(l,a[l]); seg.set(r,a[r]); }else{ print(seg.get(l,r).b); } } }