#include using namespace std; struct iofast_t { iofast_t() { ios::sync_with_stdio(false); cin.tie(nullptr); } } iofast; struct uns_t {} uns; template auto vec(Element init, Head arg, Args ...args) { if constexpr (sizeof...(Args) == 0) return std::vector(arg, init); else return std::vector(arg, vec(init, args...)); } template auto vec(uns_t, Head arg, Args ...args) { return vec(Element(), arg, args...); } template > T &chmin(T &l, T r, Compare &&f = less()) { return l = min(l, r, f); } template > T &chmax(T &l, T r, Compare &&f = less()) { return l = max(l, r, f); } #include constexpr int inf = INT_MAX / 2; int op(int x, int y) { return min(x, y); } int elem() { return inf; } using segtree = atcoder::segtree; int main() { int n, q; cin >> n >> q; auto query = vec>(uns, q); for (auto &[l, r, b] : query) { cin >> l >> r >> b; --l; } sort(rbegin(query), rend(query), [](auto x, auto y) { return get<2>(x) < get<2>(y); }); auto a = vec(uns, n); set rem; for (int i = 0; i < n; ++i) { rem.insert(i); } for (auto [l, r, b] : query) { auto iter = rem.lower_bound(l); auto last = rem.lower_bound(r); while (iter != last) { a[*iter] = b; iter = rem.erase(iter); } } segtree seg(a); for (auto [l, r, b] : query) { if (seg.prod(l, r) != b) { cout << -1 << endl; return 0; } } cout << a[0]; for (int i = 1; i < n; ++i) { cout << ' ' << a[i]; } cout << endl; }