#include using namespace std; #define MOD 1000000007 //#define MOD 998244353 #define INF 1145141919810893364 #define PI 3.141592653589 typedef pair PP; typedef long long ll; #define int ll #define setdouble setprecision #define REP(i,n) for(int i=0;i<(n);++i) #define OREP(i,n) for(int i=1;i<=(n);++i) #define RREP(i,n) for(int i=(n)-1;i>=0;--i) #define GOODBYE do { cout << -1 << endl; return 0; } while (false) #define MM <<" "<< #define Endl endl const int MAX_N=100010; int n,dat[4*MAX_N-1]; int Seg_init(int n_){ n=1; while(n0){ k=(k-1)/2; dat[k]=Seg_calc(dat[2*k+1],dat[2*k+2]); } } int Seg_query(int a,int b,int k,int l,int r){ if(r<=a||b<=l)return INT_MAX; if(a<=l&&r<=b)return dat[k]; int vl=Seg_query(a,b,2*k+1,l,(l+r)/2); int vr=Seg_query(a,b,2*k+2,(l+r)/2,r); return Seg_calc(vl,vr); } signed main(void){ int N,Q; int A[114514]; int B[114514]; int x[114514],l[114514],r[114514]; cin >> N >> Q; REP(i,N){ cin >> A[i]; } B[0]=INF; REP(i,N){ B[A[i]]=i; } REP(i,Q){ cin >> x[i] >> l[i] >> r[i]; l[i]--;r[i]--; } Seg_init(N); REP(i,N){ Seg_update(i,A[i]); } //REP(i,N+1){cout << B[i] << " ";}cout << endl; REP(i,Q){ if(x[i]==1){ swap(A[l[i]],A[r[i]]); swap(B[A[l[i]]],B[A[r[i]]]); Seg_update(l[i],A[l[i]]); Seg_update(r[i],A[r[i]]); }else{ int Ans = Seg_query(l[i],r[i]+1,0,0,N); cout << B[Ans]+1 << endl; } } //REP(i,N+1){cout << B[i] << " ";}cout << endl; return 0; }