#include using namespace std; #define int long long #define FOR(i, s, n) for (int i = (s); i < (n); i++) #define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, 0, n) #define ALL(a) a.begin(), a.end() const long long MOD = 1e9 + 7, INF = 1e18; templateinline bool CHMAX(T&a,T b){if(ainline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;} constexpr int B = 340; signed main(){ int N,Q; cin >> N >> Q; vector>a(N); vector>seg(N/B+1,{INF,INF}); vectorans; REP(i,N){ int t; cin >> t; a[i] = {t,i}; } REP(i,N){ if(seg[i/B].first > a[i].first)seg[i/B] = a[i]; } while(Q--){ int x,l,r; cin >> x >> l >> r; x--; if(x){ l--; int mi = INF,id = -1; FOR(i,l,r){ int bi = i / B; if(l <= bi * B && (bi + 1) * B <= r){ if(CHMIN(mi,seg[bi].first))id = seg[bi].second; }else{ if(CHMIN(mi,a[i].first))id = a[i].second; } } ans.push_back(id+1); }else{ l--;r--; swap(a[l].first,a[r].first); int ll = l / B; seg[ll] = {INF,INF}; REP(i,B){ if(seg[ll].first > a[ll*B+i].first)seg[ll] = a[ll*B+i]; } int rr = r / B; seg[rr] = {INF,INF}; REP(i,B){ if(seg[rr].first > a[rr*B+i].first)seg[rr] = a[rr*B+i]; } } } for(auto e:ans){ cout << e << endl; } }