// Template #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i, x) for (int i = 0; i < (x); ++i) #define rng(i, x, y) for (int i = (x); i < (y); ++i) #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() using namespace std; using ll = long long; constexpr int inf = 1001001001; constexpr ll INF = 3003003003003003003; template inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;} template inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;} void solve(); int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(10); solve(); return 0; } // Segment Tree template struct SegmentTree { Operator OP; using TypeNode = decltype(OP.NodeE); int length; vector node; SegmentTree (int N) { length = 1; while (length < N) length <<= 1; node.assign(length << 1, OP.NodeE); } SegmentTree (vector &vec) { length = 1; while (length < sz(vec)) length <<= 1; node.assign(2 * length, OP.NodeE); rep(i, sz(vec)) node[i + length] = vec[i]; for (int i = length - 1; i > 0; --i) node[i] = OP.func(node[(i << 1) + 0], node[(i << 1) + 1]); } void update(int idx, TypeNode val) { idx += length; node[idx] = OP.change(node[idx], val); while (idx >>= 1) node[idx] = OP.func(node[(idx << 1) + 0], node[(idx << 1) + 1]); } TypeNode get(int l, int r) { l += length; r += length; TypeNode vl = OP.NodeE, vr = OP.NodeE; while (r > l) { if (l & 1) vl = OP.func(vl, node[l++]); if (r & 1) vr = OP.func(node[--r], vr); l >>= 1; r >>= 1; } return OP.func(vl, vr); } }; struct hoge { using NodeType = pair; NodeType NodeE = pair(inf, -1); NodeType func(NodeType x, NodeType y) {return min(x, y);} NodeType change(NodeType x, NodeType y) {return y;} }; // Main Code void solve() { int n, q; cin >> n >> q; vector> a(n); rep(i, n) { cin >> a[i].first; a[i].second = i; } SegmentTree ST(a); rep(_, q) { int num, l, r; cin >> num >> l >> r; --l; --r; if (num == 1) { auto a = ST.node[l + ST.length], b = ST.node[r + ST.length]; a.second = r; b.second = l; ST.update(l, b); ST.update(r, a); } else { auto a = ST.get(l, r + 1); cout << a.second + 1 << "\n"; } } return; }