#pragma region #pragma GCC target("avx2") #pragma GCC optimize("03") #pragma GCC optimize("unroll-loops") #include using namespace std; typedef long double ld; typedef long long ll; typedef unsigned long long ull; #define endl "\n" #define FOR(i,a,b) for(int i=(a);i<=(b);i++) #define rep(i,a,b) for(int i=(a);i<(b);i++) #define PII pair #define PLL pair #define ALL(x) (x).begin(), (x).end() constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1; templateinline bool chmax(T &a, const T &b) { if (ainline bool chmin(T &a, const T &b) { if (b node; public: SegmentTree(vector& v) { int sz = v.size(); n = 1; while(n < sz) n *= 2; node.resize(2*n-1, {INF, INF}); for(int i=0; i=0;i--) segchmin(i); } void segchmin(int i) { if(chmin(node[i].first, node[2*i+1].first)) node[i] = node[2*i+1]; if(chmin(node[i].first, node[2*i+2].first)) node[i] = node[2*i+2]; } void update(int i, int val) { i += n-1; node[i].first = val; while(i>0) { i = (i-1)/2; segchmin(i); } } void swap(int i, int j) { int val_i = node[i+n-1].first; int val_j = node[j+n-1].first; update(i, val_j); update(j, val_i); } PII get(int a, int b, int k=0, int l=0, int r=-1) { if(r < 0) r = n; if(r <= a or b <= l) return {INF, INF}; if(a <= l and r <= b) return node[k]; auto vl = get(a,b, 2*k+1, l, (l+r)/2); auto vr = get(a,b, 2*k+2, (l+r)/2, r); return vl.first < vr.first? vl: vr; } }; int main(){ cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15); int n,Q; cin >> n >> Q; vector v(n); rep(i,0,n) cin >> v[i]; SegmentTree seg(v); while(Q--) { int num, l, r; cin >> num >> l >> r; l--, r--; if(num==1) { seg.swap(l,r); } else { cout << seg.get(l,++r).second+1 << endl; } } return 0; }