#include using namespace std; #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } #define rep(i,n) for (int i = 0; i < (n); ++i) typedef long long ll; typedef unsigned long long ull; using P=pair; const ll INF=1001001001; const int mod=1e9+7; void solve(){ int n,Q; cin>>n>>Q; vector>t(Q,vector(3)); rep(i,Q){ int l,r,b; cin>>l>>r>>b; l--; t[i]={b,l,r}; } sort(t.rbegin(),t.rend()); int pre=-1; setused,unused; rep(i,n){unused.insert(i);} vectorans(n,1e9); for(auto v:t){ int b=v[0],l=v[1],r=v[2]; if(b!=pre){ pre=b; used.clear(); } auto itr=unused.lower_bound(l); if(itr==unused.end()||*itr>=r){ auto itr2=used.lower_bound(l); if(itr2==used.end()||*itr2>=r){ cout<<-1<