// verification-helper: PROBLEM https://yukicoder.me/problems/3277 #include using namespace std; #define call_from_test template vector read(size_t n){ vector ts(n); for(size_t i=0;i>ts[i]; return ts; } template struct SegmentTree{ using F = function; int n; F f; T ti; vector dat; SegmentTree(F f,T ti):f(f),ti(ti){} void init(int n_){ n=1; while(n &v){ int n_=v.size(); init(n_); for(int i=0;i>=1) dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]); } T query(int a,int b){ if(a>=b) return ti; T vl=ti,vr=ti; for(int l=a+n,r=b+n;l>=1,r>>=1) { if(l&1) vl=f(vl,dat[l++]); if(r&1) vr=f(dat[--r],vr); } return f(vl,vr); } template int find(int st,C &check,T &acc,int k,int l,int r){ if(l+1==r){ acc=f(acc,dat[k]); return check(acc)?k-n:-1; } int m=(l+r)>>1; if(m<=st) return find(st,check,acc,(k<<1)|1,m,r); if(st<=l and !check(f(acc,dat[k]))){ acc=f(acc,dat[k]); return -1; } int vl=find(st,check,acc,(k<<1)|0,l,m); if(~vl) return vl; return find(st,check,acc,(k<<1)|1,m,r); } template int find(int st,C &check){ T acc=ti; return find(st,check,acc,1,0,n); } }; #undef call_from_test signed main(){ cin.tie(0); ios::sync_with_stdio(0); const char newl = '\n'; int n,q; cin>>n>>q; auto as=read(n); auto f=[](int a,int b){return min(a,b);}; SegmentTree seg(f,n+1); seg.build(as); for(int i=0;i>t>>l>>r; if(t==1){ l--;r--; swap(as[l],as[r]); seg.set_val(l,as[l]); seg.set_val(r,as[r]); } if(t==2){ l--; int m=seg.query(l,r); auto check=[&](int x){return x==m;}; cout<