#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #if __has_include() #include using namespace atcoder; #endif #define GET_MACRO(_1, _2, _3, NAME, ...) NAME #define _rep(i, n) _rep2(i, 0, n) #define _rep2(i, a, b) for(int i = (int)(a); i < (int)(b); i++) #define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() using i64 = long long; template bool chmin(T& a, const U& b) { return (b < a) ? (a = b, true) : false; } template bool chmax(T& a, const U& b) { return (b > a) ? (a = b, true) : false; } templateistream& operator>>(istream&i,vector&v){rep(j,v.size())i>>v[j];return i;} templatestring join(vector&v){stringstream s;rep(i,v.size())s<<' '<ostream& operator<<(ostream&o,vector&v){if(v.size())o<string join(vector>&vv){string s="\n";rep(i,vv.size())s+=join(vv[i])+"\n";return s;} templateostream& operator<<(ostream&o,vector>&vv){if(vv.size())o< struct LazySegTree{ private: int n; int log = 0; vector data; vector lazy; inline T eval_at(int x){ return mapping(data[x], lazy[x]); } inline void propagate_at(int x){ if (lazy[x] == id()) return; data[x] = eval_at(x); if (x < n){ lazy[x << 1] = composition(lazy[x << 1], lazy[x]); lazy[(x << 1) | 1] = composition(lazy[(x << 1) | 1], lazy[x]); } lazy[x] = id(); return; } void propagate_down(int x){ for (int i = log; i >= 1; i--){ if (x >> i & 1){ for (int j = i; j >= 0; j--){ propagate_at(x >> j); } return; } } } inline void merge_up(int x){ while (x > 1){ x >>= 1; data[x] = op(eval_at(x << 1), eval_at((x << 1) | 1)); } } public: LazySegTree(int n) : LazySegTree(vector(n, e())) {} LazySegTree(vector v){ while (1 << log < int(v.size())){ log++; } n = 1 << log; data.resize(n << 1, e()); lazy.resize(n << 1, id()); for (int i = 0; i < int(v.size()); i++){ data[i + n] = v[i]; } for (int i = n - 1; i >= 1; i--){ data[i] = op(data[i << 1], data[(i << 1) | 1]); } } void set(int x, T value){ x += n; propagate_down(x); data[x] = value; lazy[x] = id(); merge_up(x); } T get(int x){ propagate_down(x + n); return eval_at(x + n); } void apply(int l, int r, U value){ l += n; r += n; int lx = l / (l & -l); int rx = r / (r & -r) - 1; propagate_down(lx); propagate_down(rx); while (l < r){ if (l & 1){ lazy[l] = composition(lazy[l], value); l++; } if (r & 1){ r--; lazy[r] = composition(lazy[r], value); } l >>= 1; r >>= 1; } merge_up(lx); merge_up(rx); } T prod(int l, int r){ l += n; r += n; propagate_down(l / (l & -l)); propagate_down(r / (r & -r) - 1); T lx = e(), rx = e(); while (l < r){ if (l & 1){ lx = op(lx, eval_at(l)); l++; } if (r & 1){ r--; rx = op(eval_at(r), rx); } l >>= 1; r >>= 1; } return op(lx, rx); } T all_prod(){ return eval_at(1); } }; int op(int a, int b){ return min(a, b); } int e(){ return 1e9; } int mapping(int a, int b){ if (b == -1) return a; return max(a, b); } int composition(int a, int b){ if (b == -1) return a; return max(a, b); } int id(){ return -1; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n, q; cin >> n >> q; vector a(n, 0); LazySegTree seg(a); vector> v; while (q--){ int l, r, b; cin >> l >> r >> b; l--; seg.apply(l, r, b); v.emplace_back(l, r, b); } for (auto [l, r, b]: v){ if (seg.prod(l, r) != b){ cout << -1 << endl; assert(false); return 0; } } vector ans(n, 1); rep(i, n) ans[i] = seg.get(i); cout << ans << endl; }