#include using namespace std; //conversion //------------------------------------------ inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;} template inline string toString(T x) {ostringstream sout;sout< inline T sqr(T x) {return x*x;} //typedef //------------------------------------------ typedef long long LL; typedef pair PII; typedef pair PLL; typedef vector VI; typedef vector VVI; typedef vector VLL; typedef vector VVLL; typedef vector VB; typedef vector VVB; typedef vector VD; typedef vector VVD; typedef vector VS; typedef vector VVS; typedef vector VC; typedef vector VVC; typedef vector VPII; typedef vector VPLL; typedef priority_queue PQGI; //大きい順 typedef priority_queue> PQLI; typedef priority_queue PQGP; typedef priority_queue> PQLP; //container util //------------------------------------------ #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define EB emplace_back #define PB push_back #define PF push_front #define POB pop_back #define POF pop_front #define MP make_pair #define SZ(a) int((a).size()) #define SQ(a) ((a)*(a)) #define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define SORT(c) sort((c).begin(),(c).end()) #define SORTR(c) sort((c).rbegin(), (c).rend()) #define LB lower_bound #define UB upper_bound #define NEXP next_permutation #define FI first #define SE second #define Vmin(a) *min_element((a).begin(),(a).end()) #define Vmax(a) *max_element((a).begin(),(a).end()) //repetition //------------------------------------------ #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define FORR(i,a,b) for(int i = (b-1);i>=(a);i--) #define REPR(i,n) FORR(i,0,n) #define CFOR(i,a,b) for(int i=(a);i<=(b);++i) #define CREP(i,n) CFOR(i,0,n) #define CFORR(i,a,b) for(int i = (b);i>=(a);i--) #define CREPR(i,n) CFORR(i,0,n) #define BFOR(bit,a,b) for(int bit = (a); bit < (1<<(b)); ++bit) #define BREP(bit,n) BFOR(bit,0,n) //constant //-------------------------------------------- const double EPS = 1e-10; const double PI = acos(-1.0); const int INF = INT_MAX/2; const LL LINF = LLONG_MAX/3; const int RINF = INT_MIN/2; const LL RLINF = LLONG_MIN/3; const LL MOD = 1e9+7; const LL MODD = 998244353; const int MAX = 510000; inline bool Eq(double a, double b) { return fabs(b - a) < EPS; } //other //------------------------------------------- templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b0){ if(N&1) res = res * A % M; A = A * A % M; N >>= 1; } return res; } template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; } template< typename T1, typename T2 > ostream &operator<<(ostream &os, const pair< T1, T2 >& p) { os << p.first << " " << p.second; return os; } template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; } template< typename T > ostream &operator<<(ostream &os, const vector< T > &v) { for(int i = 0; i < (int) v.size(); i++) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } template vector make_v(size_t a,T b){return vector(a,b);} template auto make_v(size_t a,Ts... ts){ return vector(a,make_v(ts...)); } template struct SegmentTree{ using OP = function; int n; vector node; T t; OP op; SegmentTree(int n_, T t, OP op) : t(t),op(op){ n = 1; while(n < n_) n<<=1; node.assign(2*n,t); } void init(int n_){ n = 1; while(n < n_) n<<=1; node.assign(2*n,t); } void set(int k,T x){ node.at(k+n) = x; } void build(){ for(int k = n - 1; k > 0; k--){ node.at(k) = op(node.at(2*k),node.at(2*k+1)); } } void update(int k, T x){ k += n; node.at(k) = x; while(k >>= 1){ node.at(k) = op(node.at(2*k),node.at(2*k+1)); } } void update(int l, int r, T x){ FOR(k,l,r) update(k,x); } T at(int k){ return node.at(k+n); } void add(int k, T a){ T x = at(k)+a; update(k,x); } T query(int a, int b){ T L = t, R = t; for(a += n, b += n; a < b; a >>= 1, b >>= 1) { if(a & 1) L = op(L, node.at(a++)); if(b & 1) R = op(node.at(--b), R); } return op(L, R); } template int findR(int a, int b, C &check){ return findR(a,b,check,1,0,n); } template int findR(int a, int b, C &check, int k, int l, int r){ if(!check(node.at(k))||r<=a||b<=l) return -1; if(k >= n) return k-n; int rv = findR(a,b,check,2*k+1,(l+r)/2,r); if(rv != -1) return rv; return findR(a,b,check,2*k,l,(l+r)/2); } template int findL(int a, int b, C &check){ return findL(a,b,check,1,0,n); } template int findL(int a, int b, C &check, int k, int l, int r){ if(!check(node.at(k))||r<=a||b<=l) return -1; if(k >= n) return k-n; int lv = findL(a,b,check,2*k,l,(l+r)/2); if(lv != -1) return lv; return findL(a,b,check,2*k+1,(l+r)/2,r); } }; int main() { // cin.tie(0); // ios::sync_with_stdio(false); cout << fixed << setprecision(12); int N,Q; cin >> N >> Q; VI a(N); cin >> a; SegmentTree seg( N, MP(INF,0), [](PII a, PII b){return min(a,b);} ); REP(i,N){ seg.set(i,MP(a.at(i),i+1)); } seg.build(); REP(q,Q){ int p,l,r; cin >> p >> l >> r; if(p==1){ swap(a.at(--l),a.at(--r)); seg.update(l,MP(a.at(l),l+1)); seg.update(r,MP(a.at(r),r+1)); }else{ PII res = seg.query(--l,r); COUT(res.SE); } } return 0; }