#include using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using P = pair; using tp = tuple; template using vec = vector; template using vvec = vector>; #define all(hoge) (hoge).begin(), (hoge).end() #define en '\n' #define rep(i, m, n) for(ll i = (ll)(m); i < (ll)(n); ++i) #define rep2(i, m, n) for(ll i = (ll)(n)-1; i >= (ll)(m); --i) #define REP(i, n) rep(i, 0, n) #define REP2(i, n) rep2(i, 0, n) constexpr long long INF = 1LL << 60; constexpr int INF_INT = 1 << 25; constexpr long long MOD = (ll)1e9 + 7; //constexpr long long MOD = 998244353LL; static const ld pi = 3.141592653589793L; #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") template inline bool chmin(T &a, T b) { if(a > b) { a = b; return true; } return false; } template inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } //グラフ関連 struct Edge { int to, rev; ll cap; Edge(int _to, int _rev, ll _cap) : to(_to), rev(_rev), cap(_cap) {} }; typedef vector Edges; typedef vector Graph; void add_edge(Graph &G, int from, int to, ll cap, bool revFlag, ll revCap) { G[from].push_back(Edge(to, (int)G[to].size(), cap)); if(revFlag) G[to].push_back(Edge(from, (int)G[from].size() - 1, revCap)); } template class SegmentTree { private: T e; F op; U st; ll n; vector dat; public: SegmentTree(F f, U u, T _e, vector v) : op(f), st(u), e(_e) { int _n = v.size(); n = 1; while(n < _n) n *= 2; dat.resize(2 * n - 1, e); REP(i, _n) dat[n + i - 1] = v[i]; for(int i = n - 2; i >= 0; i--) dat[i] = op(dat[i * 2 + 1], dat[i * 2 + 2]); } SegmentTree(F f, U u, T _e, int _n) : op(f), st(u), e(_e) { n = 1; while(n < _n) n *= 2; dat.resize(2 * n - 1, e); for(int i = n - 2; i >= 0; i--) dat[i] = op(dat[i * 2 + 1], dat[i * 2 + 2]); } void update(int i, T x) { i += n - 1; dat[i] = st(dat[i], x); while(i > 0) { i = (i - 1) / 2; dat[i] = op(dat[i * 2 + 1], dat[i * 2 + 2]); } } T get(int i) { i += n - 1; return dat[i]; } T query(int l, int r) { //[l,r)でのクエリ処理 T left = e, right = e; l += n - 1; r += n - 1; while(l < r) { if((l & 1) == 0) left = op(left, dat[l]); if((r & 1) == 0) right = op(dat[r - 1], right); l = l / 2; r = (r - 1) / 2; } return op(left, right); } }; void solve() { ll n, q; cin >> n >> q; vec

ls, rs; vec lrb; REP(i, q) { ll l, r, b; cin >> l >> r >> b; l--; lrb.push_back({l, r, b}); ls.push_back({l, b}); rs.push_back({r, b}); } sort(all(ls)); sort(all(rs)); ll pr = 0; ll pl = 0; using S = ll; S id = INF; auto op = [](S a, S b) { return min(a, b); }; auto st = [](S a, S b) { return min(a, b); }; SegmentTree seg(op, st, id, n); multiset set; REP(i, n) { while(pr < q) { auto [r, b] = rs[pr]; if(r != i) break; auto it = set.find(b); set.erase(it); pr++; } while(pl < q) { auto [l, b] = ls[pl]; if(l != i) break; set.insert(b); pl++; } if(set.size()) { auto it = --set.end(); ll x = *it; seg.update(i, x); } else { seg.update(i, 1e9); } } REP(i, q) { auto [l, r, b] = lrb[i]; if(seg.query(l, r) != b) { cout << -1 << en; return; } } REP(i, n) { cout << seg.get(i) << " "; } cout << en; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); //cout << fixed << setprecision(10); // ll t; // cin >> t; // REP(i, t - 1) { // solve(); // } solve(); return 0; }