#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using ll = long long; using P = std::pair; #define rep(i, a, b) for (ll(i) = (a); i < (b); i++) #define all(i) i.begin(), i.end() #define debug(i) std::cerr << "debug " << #i<<" "< std::ostream& operator<<(std::ostream& os, std::pair pa) { return os << pa.first << " " << pa.second; } template std::ostream& operator<<(std::ostream& os, std::vector vec) { for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " "); return os; } template inline bool chmax(T1& a,T2 b){return a inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);} ll pow_mod(ll a, ll b, ll mod=-1) { if ((a == 0)||(mod!=-1&&a%mod==0)) { return 0; } ll x = 1; while (b > 0) { if (b & 1) { x = (mod!=-1)?(x * a) % mod:x*a; } a = (mod!=-1)?(a * a) % mod:a*a; b >>= 1; } return x; } // const ll MOD = 998244353; const ll MOD = 1e9 + 7; //非再帰抽象セグ木 0-indexed 単位元はiで指定 template class SegmentTree { private: long long n; T init; std::vector dat; F fn; public: SegmentTree(long long i, T para, F fun) : init(para), fn(fun) { n = 1; while (n < i) { n *= 2; } dat = std::vector(2 * n - 1, init); } // k番目(0-indexed)を値aで更新,dest=trueのときは更新前を破壊する void update(long long k, T a, bool dest) { k += n - 1; if (dest) dat[k] = a; else dat[k] = fn(dat[k], a); while (k > 0) { k = (k - 1) / 2; dat[k] = fn(dat[k * 2 + 1], dat[k * 2 + 2]); } } T query(long long a, long long b){ assert(0<=a&&b<=n); T val=init; long long l=a+n-1,r=b+n-1; for(;l>1),r=(r>>1)){ if(!(r&1)){ r--; val=fn(val,dat[r]); } if(!(l&1)){ val=fn(val,dat[l]); l++; } } return val; } }; int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); ll n,q; std::cin>>n>>q; auto f=[](P x,P y){return (x.first a(n+2,P(MOD,-1),f); rep(i,0,n){ ll temp; std::cin>>temp; a.update(i,P(temp,i),true); } rep(i,0,q){ ll query,l,r; std::cin>>query>>l>>r; l--;r--; if(query==1){ P al=a.query(l,l+1),ar=a.query(r,r+1); a.update(l,P(ar.first,l),true);a.update(r,P(al.first,r),true); }else{ std::cout<