using P=pair>; P a[2d5]; ll s[2d5]; ll z[2d5]; { ll@n,@q; rep(i,q){ ll@l,@r,@b; a[i]={-b,{r,l-1}}; } sortA(q,a); ll fb=0,fi=0; rep(i,q){ ll b=-a[i].first; ll l=a[i].second.second; ll r=a[i].second.first; ll f=(fb==b&&fi>=l); while(1){ ll t=l; while(t=r){ break; } f=1; s[l]=l+1; z[l]=b; if(!(fb==b&&fi>=l)){ fb=b; fi=l; } } if(!f){ wt(-1); exit(0); } } rep(i,n){ if(!z[i]){ z[i]=1; } } wt(z(n)); }