#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a>n>>q; vector as(n); for(int i=0;i>as[i]; for(int i=0;i>t; if(t==1){ int l,r; cin>>l>>r; l--;r--; swap(as[l],as[r]); } if(t==2){ int l,r; cin>>l>>r; l--; int k=l,val=as[l]; for(int j=l;jas[j]) k=j,val=as[j]; } cout<