#include using namespace std; #define ll long long #define ld long double #define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--) #define rrep(i,n) RREP(i,(n)-1,0) #define all(v) v.begin(), v.end() #define endk '\n' const int inf = 1e9+7; const ll longinf = 1LL<<60; const ll mod = 1e9+7; const ll mod2 = 998244353; const ld eps = 1e-10; template inline void chmin(T1 &a, T2 b){if(a>b) a=b;} template inline void chmax(T1 &a, T2 b){if(a struct SegmentTree { using F = function< Monoid(Monoid, Monoid) >; int sz; int _n; vector< Monoid > seg; const F f; const Monoid M1; SegmentTree(int n, const F f, const Monoid &M1) : _n(n), f(f), M1(M1) { sz = 1; while(sz < n) sz <<= 1; seg.assign(2 * sz, M1); } void set(int p, const Monoid &x) { assert(0 <= p && p < _n); seg[p + sz] = x; } void build() { for(int k = sz - 1; k > 0; k--) { seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]); } } void update(int p, const Monoid &x) { assert(0 <= p && p < _n); p += sz; seg[p] = x; while(p >>= 1) { seg[p] = f(seg[2 * p + 0], seg[2 * p + 1]); } } Monoid query(int l, int r) { assert(0 <= l && l <= r && r <= _n); Monoid L = M1, R = M1; for(l += sz, r += sz; l < r; l >>= 1, r >>= 1) { if(l & 1) L = f(L, seg[l++]); if(r & 1) R = f(seg[--r], R); } return f(L, R); } Monoid get(const int &p) const { assert(0 <= p && p < _n); return seg[p + sz]; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, q; cin >> n >> q; multiset st; vector> in; vector> A; rep(i, q) { int l, r, b; cin >> l >> r >> b; l--; in.push_back({l, r, b}); A.push_back({l, 1, b}); A.push_back({r, -1, b}); } sort(all(A)); vector mn(n, 1000000000); int l = 0; rep(i, n) { while(l < 2*n && get<0>(A[l]) == i) { auto [p, t, b] = A[l]; if(t == -1) { assert(st.find(b) != st.end()); st.erase(st.find(b)); } else { st.insert(b); } l++; } if(st.empty()) continue; mn[i] = *(--st.end()); } SegmentTree seg(n, [](int a, int b) { return min(a, b); }, INT_MAX); rep(i, n) seg.update(i, mn[i]); for(auto [l, r, b]: in) { if(seg.query(l, r) != b) { cout << -1 << endk; return 0; } } rep(i, n) cout << mn[i] << ' '; cout << endk; return 0; }