//#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") #include using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair; template using V = vector; template using VV = V>; template V make_vec(size_t a) { return V(a); } template auto make_vec(size_t a, Ts... ts) { return V(ts...))>(a, make_vec(ts...)); } #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define rep(i, n) rep2(i, 0, n) #define rep2(i, m, n) for (int i = m; i < (n); i++) #define per(i, b) per2(i, 0, b) #define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--) #define ALL(c) (c).begin(), (c).end() #define SZ(x) ((int)(x).size()) constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); } template void chmin(T& t, const U& u) { if (t > u) t = u; } template void chmax(T& t, const U& u) { if (t < u) t = u; } template ostream& operator<<(ostream& os, const pair& p) { os << "(" << p.first << "," << p.second << ")"; return os; } template ostream& operator<<(ostream& os, const vector& v) { os << "{"; rep(i, v.size()) { if (i) os << ","; os << v[i]; } os << "}"; return os; } #ifdef LOCAL void debug_out() { cerr << endl; } template void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...); } #define debug(...) \ cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl #else #define debug(...) (void(0)) #define dump(x) (void(0)) #endif template void print(T x, int suc = 1) { cout << x; if (suc == 1) cout << "\n"; else if (suc == 2) cout << " "; } template void print(const vector& v, int suc = 1) { for (int i = 0; i < v.size(); ++i) print(v[i], i == int(v.size()) - 1 ? suc : 2); } // index of root = 1 template struct segtree { using T = typename U::T; int sz; V dat; segtree() {} segtree(int n) { sz = 1; while (sz < n) sz <<= 1; dat.assign(sz * 2, U::id()); } segtree(const V& a) { int n = a.size(); sz = 1; while (sz < n) sz <<= 1; dat.assign(sz * 2, U::id()); for (int i = 0; i < n; ++i) { dat[sz + i] = a[i]; } for (int i = sz - 1; i >= 1; --i) { upd(i); } } void upd(int p) { dat[p] = U::op(dat[p << 1], dat[p << 1 | 1]); } void build() { for (int i = sz - 1; i > 0; --i) { dat[i] = U::op(dat[i << 1], dat[i << 1 | 1]); } } void modify(int p, T v) { p += sz; dat[p] = v; while (p >>= 1) { dat[p] = U::op(dat[p << 1], dat[p << 1 | 1]); } } //[l, r) T query(int l, int r) { T lval = U::id(), rval = U::id(); for (l += sz, r += sz; l < r; l >>= 1, r >>= 1) { if (l & 1) lval = U::op(lval, dat[l++]); if (r & 1) rval = U::op(dat[--r], rval); } return U::op(lval, rval); } }; // modify only U for use constexpr int INF = TEN(9) + 10; struct U { using T = int; static T id() { return INF; } static T op(const T& a, const T& b) { return min(a, b); } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N, Q; cin >> N >> Q; VV ev(N + 1); V> vec; rep(i, Q) { int l, r, x; cin >> l >> r >> x; --l; ev[l].eb(-1, x); ev[r].eb(1, x); vec.eb(l, r, x); } multiset st; st.insert(0); V A(N); rep(i, N) { sort(ALL(ev[i])); for (auto p : ev[i]) { if (p.fi == -1) { st.insert(p.se); } else { st.erase(st.find(p.se)); } } A[i] = *st.rbegin(); } segtree seg(A); bool ok = 1; for (auto& [l, r, x] : vec) { if (seg.query(l, r) != x) { ok = 0; } } if (ok) { print(A); } else { cout << -1 << endl; } return 0; }