#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define N (1000000000+7) //#define N 998244353 #define INF 1e16 typedef long long ll; typedef pair P; typedef pair Q; const int inf = (int)1e9; ll gcd(ll a, ll b) { if (b > a) { ll tmp = b; b = a; a = tmp; } if (a%b == 0)return b; else return gcd(b, a%b); } template struct SegmentTree{ typedef function F; int n; F f; T unit; vector dat; SegmentTree(){}; SegmentTree(int newn,F f,T t):f(f),unit(t){ init(newn); } SegmentTree(const vector &v,F f,T t):f(f),unit(t){ int n_ = v.size(); init(n_); for(int i=0;i>=1) dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]); } T query(int a,int b){ T vl=unit,vr=unit; for(int l=a+n,r=b+n;l>=1,r>>=1){ if(l&1)vl=f(vl,dat[l++]); if(r&1)vr=f(dat[--r],vr); } return f(vl,vr); } }; int main(void){ int n,q; cin>>n>>q; auto f = [](P l,P r){ if(l.second>r.second)return r; else return l; }; SegmentTree

seg = SegmentTree

(n,f,P(-1,inf)); for(int i=0;i>a; seg.update(i,P(i,a)); } for(int i=0;i>c; if(c==1){ int l,r; cin>>l>>r; P tmp1 = seg.query(l-1,l); int vl = tmp1.second; P tmp2 = seg.query(r-1,r); int vr = tmp2.second; seg.update(l-1,P(l-1,vr)); seg.update(r-1,P(r-1,vl)); } else{ int l,r; cin>>l>>r; P ans = seg.query(l-1,r); cout<