#include using namespace std; using ll = long long; using VI = vector; using VL = vector; #define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++) #define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++) #define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--) #define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--) #define SORT(i) sort((i).begin(),(i).end()) #define rSORT(i,a) sort((i).begin(),(i).end(),(a)) #define all(i) (i).begin(),(i).end() constexpr ll INF = 1000000000; constexpr ll LLINF = 1LL << 60; constexpr ll mod = 1000000007; constexpr ll MOD = 998244353; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; } inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } struct p {int num, itr;}; bool operator < (const p& a, const p& b) { return a.num < b.num; } bool operator > (const p& a, const p& b) { return a.num > b.num; } bool operator == (const p& a, const p& b) { return a.num == b.num; } template class segtree { vector dat; int n = 1; public: #define def {INF,-1} segtree(int _n){ while (n < _n)n *= 2; dat.resize(2 * n - 1 , def); } segtree(vector a) { int size = a.size(); while (n < size)n *= 2; dat.resize(2 * n - 1, def); FOR(i, 0, size)dat[i + n - 1] = a[i]; rFOR(i, 0, n - 1)dat[i] = fun(dat[2 * i + 1], dat[2 * i + 2]); } T fun(T x, T y) { return min(x, y); } void update(int i, T x) { i += n - 1; dat[i] = x; while (i > 0) { --i /= 2; dat[i] = fun(dat[i * 2 + 1], dat[i * 2 + 2]); } } T query(int a, int b, int k, int l, int r) { if (r <= a || b <= l)return def; else if (a <= l && r <= b)return dat[k]; else { T s = query(a, b, k * 2 + 1, l, (l + r) / 2); T t = query(a, b, k * 2 + 2, (l + r) / 2, r); return fun(s, t); } } T query(int a, int b) { return query(a, b, 0, 0, n); } void datswap(int a, int b) { a += n - 1, b += n - 1; swap(dat[a].num, dat[b].num); while (a > 0) { --a /= 2; dat[a] = fun(dat[a * 2 + 1], dat[a * 2 + 2]); } while (b > 0) { --b /= 2; dat[b] = fun(dat[b * 2 + 1], dat[b * 2 + 2]); } } }; int main() { init(); int n, q; cin >> n >> q; vector

in(n); FOR(i, 0, n) { cin >> in[i].num; in[i].itr = i; } segtree

seg(in); int num, l, r; while (q--) { cin >> num >> l >> r; if (num == 1)seg.datswap(--l, --r); else cout << seg.query(--l, r).itr+1 << "\n"; } }