#include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; const static int INF = 10000000; struct ST { int x, y; ST():x(INF),y(INF){} ST(int x, int y):x(x),y(y){} }; ST combine(const ST& lhs, const ST& rhs){ ST st; if(lhs.x < rhs.x){ st = lhs; }else{ st = rhs; } return st; } template class SegmentTree { int N; vector t; void build(){ for(int i=N-1; i>0; i--){ t[i] = combine(t[i<<1], t[i<<1|1]); } } public: SegmentTree(int n_){ N = 1; while(N < n_) N *= 2; t.resize(2*N); for(int i=N; i<2*N; i++){ t[i] = S(); } build(); } SegmentTree(const vector& v){ N = 1; while(N < v.size()) N *= 2; t.resize(2*N); for(int i=0; i>=1;){ t[p] = combine(t[p<<1], t[p<<1|1]); } } S query(int l, int r){ S resl, resr; for(l+=N, r+=N; l>=1, r>>=1){ if(l&1) resl = combine(resl, t[l++]); if(r&1) resr = combine(t[--r], resr); } return combine(resl, resr); } }; int main(){ int N, Q; cin >> N >> Q; SegmentTree segtree(N); rep(i,N){ int a; cin >> a; segtree.modify(i,ST(a,i)); } rep(i,Q){ int x, l, r; cin >> x >> l >> r; l--; r--; if(x == 1){ ST lhs = segtree.query(l,l+1); ST rhs = segtree.query(r,r+1); swap(lhs.y, rhs.y); segtree.modify(l,rhs); segtree.modify(r,lhs); }else{ ST ret = segtree.query(l,r+1); cout << ret.y+1 << endl; } } return 0; }