#include using namespace std; typedef long long ll; #define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++) #define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++) #define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--) #define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--) #define all(x) (x).begin(), (x).end() #define sz(x) ((ll)(x).size()) #define len(x) ((ll)(x).length()) template struct SegmentTree { private: int n; vector node; T def; function lop; function out; public: SegmentTree() {} SegmentTree(const vector &v, T _def, function _lop, function _out) { int vl = (int)v.size(); n = 1; while(n < vl) n *= 2; def = _def; lop = _lop; out = _out; node = vector(2 * n - 1, def); for(int i = 0; i < vl; i++) node[i + n - 1] = v[i]; for(int i = n - 2; i >= 0; i--) node[i] = out(node[i * 2 + 1], node[i * 2 + 2]); } void update(int idx, T val) { idx += (n - 1); node[idx] = lop(node[idx], val); while(idx > 0) { idx = (idx - 1) / 2; node[idx] = out(node[idx * 2 + 1], node[idx * 2 + 2]); } } T query(int a, int b, int k = 0, int l = 0, int r = -1) { if (r < 0) r = n; if ((r <= a) || (b <= l)) return def; if ((a <= l) && (r <= b)) return node[k]; return out(query(a, b, 2 * k + 1, l, (l + r) / 2), query(a, b, 2 * k + 2, (l + r) / 2, r)); } }; int main() { cin.tie(0); ios::sync_with_stdio(false); // ifstream in("input.txt"); // cin.rdbuf(in.rdbuf()); ll n, q; cin >> n >> q; vector> a(n); rep(i, n) { cin >> a[i].first; a[i].second = i; } auto lop = [](pair a, pair b){ return b; }; auto out = [](pair a, pair b){ return min(a, b); }; SegmentTree> st(a, make_pair(LONG_LONG_MAX, -1), lop, out); rep(i, q) { ll com, l, r; cin >> com >> l >> r; l--; r--; if (com == 1) { pair v1 = st.query(l, l + 1); pair v2 = st.query(r, r + 1); swap(v1.first, v2.first); st.update(l, v1); st.update(r, v2); } else { cout << (st.query(l, r + 1).second + 1) << endl; } } return 0; }