#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include using namespace std; template struct SegTreeLazy { using FX=function; using FA=function; using FM=function; int n; FX fx; FA fa; FM fm; const X ex; const M em; vector dat; vector lazy; SegTreeLazy(int n_,FX fx_,FA fa_,FM fm_,X ex_,M em_) : n(),fx(fx_),fa(fa_),fm(fm_),ex(ex_),em(em_),dat(n_*4,ex),lazy(n_*4,em) { int x=1; while (n_ > x) x *= 2; n=x; } void set(int i,X x) { dat[i+n-1]=x;} void build() { for (int k=n-2;k >= 0;k--) dat[k]=fx(dat[2*k+1],dat[2*k+2]); } /* lazy eval */ void eval(int k) { if(lazy[k] == em) return; // 更新するものが無ければ終了 if(k>n>>q; vector L(q),R(q),B(q); rep(i,q) cin>>L[i]>>R[i]>>B[i]; vector>> A(q); rep(i,q) A[i]={B[i],{L[i],R[i]}}; sort(ALL(A)); using X=int; using M=int; auto fx=[](X x1,X x2) -> X { return min(x1,x2);}; auto fa=[](X x,M m) -> X { return m;}; auto fm=[](M m1,M m2) -> M { return m2;}; X ex=1000000000; M em=1000000000; SegTreeLazy lseg(n,fx,fa,fm,ex,em); rep(i,q){ lseg.update(A[i].second.first,A[i].second.second+1,A[i].first); } bool b=true; rep(i,q){ if(A[i].first!=lseg.query(A[i].second.first,A[i].second.second+1)) b=false; } if(b==false){ cout<<-1<1) cout<<" "; cout<