#include using namespace std; typedef long long ll; #define P pair #define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I) #define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I) #define TO(x,t,f) ((x)?(t):(f)) #define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9 #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v x is sorted #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v x is sorted #define NUM(x,v) (POSU(x,v)-POSL(x,v)) //x is sorted #define REV(x) (reverse(x.begin(),x.end())) //reverse ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);} ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);} #define NEXTP(x) next_permutation(x.begin(),x.end()) const ll INF=ll(1e18)+ll(7); const ll MOD=1000000007LL; #define out(a) cout< struct RMQ{// 0-index int n,rn,bn; // rn個のかたまりをbn個 vector data,bucket,indbucket; RMQ(int n_){init(n_);} void init(int n_){ n = n_; rn = sqrt(n); bn = ceil((double)n/rn); data.resize(n,0); bucket.resize(bn,0); indbucket.resize(bn,0); } T get(int i){ return data[i]+bucket[i/rn]; } int get_index(int l,int r){ int res = -1; int minx = 300000000; FOR(j,l,r+1){ if(j%rn==0 && (j+rn)<=r){ if(minx>bucket[j/rn]){ minx = bucket[j/rn]; res = indbucket[j/rn]; } }else{ if(minx>data[j]){ minx = data[j]; res = j; } } } return res; } void change(int i,T x){ //i番目をxに data[i] = x; int ind = i/rn; bucket[ind] = 300000000; FOR(j,ind*rn,(ind+1)*rn){ if(bucket[ind]>data[j]){ bucket[ind] = data[j]; indbucket[ind] = j; } } } }; int main(){ int N,a,Q; cin >> N >> Q; RMQ rmq(N+2); FOR(i,0,N){ cin >> a; rmq.change(i+1,a); } FOR(i,0,Q){ int q,l,r; cin >> q >> l >> r; if(q==1){ int al = rmq.data[l]; int ar = rmq.data[r]; rmq.change(l,ar); rmq.change(r,al); }else{ cout << rmq.get_index(l,r) << endl; } } }