#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include <atcoder/all> #include <bits/stdc++.h> using namespace std; using namespace atcoder; struct S{ int a,i; }; const int INF=1e9; S op(S x,S y){ if(x.a<y.a) return x; return y; } S e(){return S{INF,-1};} int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n,q; cin>>n>>q; vector<S> A(n); rep(i,n){ int a; cin>>a; A[i]=S{a,i}; } segtree<S,op,e> seg(A); while(q--){ int c; cin>>c; if(c==1){ int l,r; cin>>l>>r; l--,r--; auto a=seg.get(l),b=seg.get(r); seg.set(l,S{b.a,l}),seg.set(r,S{a.a,r}); } else{ int l,r; cin>>l>>r; l--,r--; auto c=seg.prod(l,r+1); cout<<c.i+1<<'\n'; } } return 0; }