#include using namespace std; using lint = long long; template using V = vector; template using VV = V< V >; struct SegmentTree { using T = pair; static T op(const T& a, const T& b) { return min(a, b); } static constexpr T e() { return {2e9, -1}; } const int n; V t; SegmentTree(int n) : n(n), t(2 * n, e()) {} T& operator[](int i) { return t[i + n]; } void build() { for (int i = n - 1; i; --i) t[i] = op(t[2 * i], t[2 * i + 1]); } T acc(int l, int r) const { T resl = e(), resr = e(); for (l += n, r += n; l < r; l >>= 1, r >>= 1) { if (l & 1) resl = op(resl, t[l++]); if (r & 1) resr = op(t[--r], resr); } return op(resl, resr); } void set(int i, const T& a) { t[i += n] = a; while (i >>= 1) t[i] = op(t[2 * i], t[2 * i + 1]); } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, q; cin >> n >> q; SegmentTree st(n); for (int i = 0; i < n; ++i) { int a; cin >> a; st[i] = {a, i}; } st.build(); while (q--) { int tp; cin >> tp; if (tp == 1) { int l, r; cin >> l >> r, --l, --r; int vl = st[l].first, vr = st[r].first; st.set(l, {vr, l}); st.set(r, {vl, r}); } else { int l, r; cin >> l >> r, --l; cout << st.acc(l, r).second + 1 << '\n'; } } }