#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a struct SegmentTree{ using F = function; Int n; F f; T ti; vector dat; SegmentTree(){}; SegmentTree(F f,T ti):f(f),ti(ti){} void init(Int n_){ n=1; while(n &v){ 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=ti,vr=ti; 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); } }; struct FastIO{ FastIO(){ cin.tie(0); ios::sync_with_stdio(0); } }fastio_beet; template vector compress(vector v){ sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end()); return v; } template map dict(const vector &v){ map res; for(Int i=0;i<(Int)v.size();i++) res[v[i]]=i; return res; } //INSERT ABOVE HERE signed main(){ Int n; cin>>n; vector a(n),b(n),c(n); for(Int i=0;i>a[i]>>b[i]>>c[i]; { using T = tuple; vector vt; for(Int i=0;i vs(b); vs.emplace_back(0); vs.emplace_back(1e9+100); vs=compress(vs); auto dc=dict(vs); auto f=[](Int a,Int b){return max(a,b);}; SegmentTree seg(f,0); seg.build(vector(vs.size(),0)); for(Int i=0;i