#include #include #include #include #include using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(n); i++) namespace RQ{ using S = int; S e(){ return 1000000000; }; S op(S l, S r){ return 1000000000; }; using F = int; S mapping(F f, S x){ if(f == -1) return x; return f; } F composition(F f, F x){ if(f == -1) return x; return f; } F id(){ return -1; } using RQ = atcoder::lazy_segtree; } namespace RMQ{ using S = int; S e(){ return 1000000000; }; S op(S l, S r){ return min(l,r); }; using RQ = atcoder::segtree; } struct Query{ int l,r,q; }; int main(){ int N,Q; cin >> N >> Q; vector queries(Q); for(auto& a : queries){ cin >> a.l >> a.r >> a.q; a.l--; } sort(queries.begin(), queries.end(), [](Query l, Query r)->bool{ return l.q < r.q; }); RQ::RQ rq(N); for(auto a : queries) rq.apply(a.l, a.r, a.q); vector A(N); rep(i,N) A[i] = rq.get(i); RMQ::RQ rmq(A); bool ok = true; for(auto a : queries) if(rmq.prod(a.l, a.r) != a.q) ok = false; if(!ok){ cout << "-1\n"; return 0; } rep(i,N){ if(i) cout << " "; cout << A[i]; } cout << "\n"; return 0; } struct ios_do_not_sync { ios_do_not_sync() { ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;