#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair PII; typedef vector VI; typedef vector VVI; #define MP make_pair #define PB push_back #define inf 1000000007 #define mod 1000000007 #define rep(i,n) for(int i=0;i<(int)(n);++i) template class segtree { private: int n,sz; vector > node; public: segtree(vector& v) : sz((int)v.size()){ n = 1; while(n < sz){ n *= 2; } node.resize(2*n, make_pair(numeric_limits::max(), -1)); for(int i = 0; i < sz; i++){ node[i+n] = make_pair(v[i], i); } for(int i=n-1; i>=1; i--){ node[i] = min(node[2*i], node[2*i+1]); } } void update(int k, T a) { node[k+n] = make_pair(a, k); k+=n; while(k>>=1){ node[k] = min(node[2*k], node[2*k+1]); } } pair query(int a,int b,int k=0,int l=0,int r=-1) { pair res1 = make_pair(numeric_limits::max(), -1); pair res2 = make_pair(numeric_limits::max(), -1); a += n, b += n; while(a != b){ if(a % 2) res1 = min(res1, node[a++]); if(b % 2) res2 = min(res2, node[--b]); a >>= 1, b>>= 1; } return min(res1, res2); } void print() { for(int i = 0; i < sz; i++){ pair p; p = query(i,i+1); cout << "st[" << i << "]: " << p.fi << " " << p.se << endl; } } }; int main(){ int n,q; cin >> n >> q; vectora(n); rep(i,n)cin >> a[i]; segtreesg(a); rep(i,q){ int c,l,r; cin >> c >> l >> r; l--;r--; if(c==1){ int p = sg.query(l,l+1).first; int q = sg.query(r,r+1).first; sg.update(l,q); sg.update(r,p); }else{ cout << sg.query(l,r+1).second+1 << endl; } } return 0; }