#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll=long long; template using V = vector; template using P = pair; using vll = V; using vvll = V; #define rep(i, k, n) for (ll i=k; i<(ll)n; ++i) #define REP(i, n) rep(i, 0, n) #define ALL(v) v.begin(),v.end() template inline bool chmax(T& a, T b) {if (a inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;} const ll MOD = 1000000007; const ll HIGHINF = (ll)1e18; template < typename T > struct SegmentTree { vector data; long long n; SegmentTree(vector vec) { long long sz = vec.size(); n=1; while(n=0; i--) { if (data[2*i+1].second > data[2*i+2].second) data[i] = data[2*i+2]; else data[i] = data[2*i+1]; } } void update(ll val1, ll val2) { val1 += (n-1); val2 += (n-1); ll tmp = data[val1].second; data[val1].second = data[val2].second; data[val2].second = tmp; while(val1 > 0) { val1 = (val1-1) / 2; if (data[2*val1+1].second > data[2*val1+2].second) data[val1] = data[2*val1*2]; else data[val1] = data[2*val1*1]; } while(val2 > 0) { val2 = (val2-1) / 2; if (data[2*val2+1].second > data[2*val2+2].second) data[val2] = data[2*val2*2]; else data[val2] = data[2*val2*1]; } } T query(long long l, long long r) { T ret = make_pair(0, HIGHINF); l += (n-1), r += (n-1); while (l < r) { if ((l & 1LL) == 0LL) { if (ret.second > data[l].second) ret = data[l]; } if ((r & 1LL) == 0LL) { if (ret.second > data[r-1].second) ret = data[r-1]; } l /= 2; r = (r-1) / 2; } return ret; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); ll n, q; cin >> n >> q; V > a(n); REP(i, n) { ll tmpa; cin >> tmpa; a[i] = make_pair(i, tmpa); } SegmentTree > seg = SegmentTree >(a); REP(_, q) { ll qi, l, r; cin >> qi >> l >> r; if (qi == 1) { seg.update(l-1, r-1); } else { P ans = seg.query(l-1, r); cout << ans.first+1 << '\n'; } } return 0; }