#include #include using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < int(n); i++) #define all(v) v.begin(), v.end() using S = int; using F = int; S op(S a, S b) { return min(a, b); } S e() { return int(1e9); } S mapping(F x, S a) { return x == -1 ? a : x; } F composition(F f, F g) { return f == -1 ? g : f; } F id() { return -1; } int main() { int n, q; cin >> n >> q; vector> query(q); rep(i, q) { int l, r, b; cin >> l >> r >> b; l--; query[i] = {b, l, r}; } sort(all(query)); atcoder::lazy_segtree seg(n); for (auto [b, l, r] : query) seg.apply(l, r, b); for (auto [b, l, r] : query) { if (seg.prod(l, r) != b) { cout << -1 << "\n"; return 0; } } rep(i, n) cout << seg.get(i) << (i + 1 == n ? "\n" : " "); }