#include using namespace std; // clang-format off #include #include #include #ifdef _MSC_VER #include #endif namespace atcoder { namespace internal { int ceil_pow2(int n) { int x = 0; while ((1U << x) < (unsigned int)(n)) x++; return x; } constexpr int bsf_constexpr(unsigned int n) { int x = 0; while (!(n & (1 << x))) x++; return x; } int bsf(unsigned int n) { #ifdef _MSC_VER unsigned long index; _BitScanForward(&index, n); return index; #else return __builtin_ctz(n); #endif } } // namespace internal } // namespace atcoder namespace atcoder { template struct segtree { public: segtree() : segtree(0) {} explicit segtree(int n) : segtree(std::vector(n, e())) {} explicit segtree(const std::vector& v) : _n(int(v.size())) { log = internal::ceil_pow2(_n); size = 1 << log; d = std::vector(2 * size, e()); for (int i = 0; i < _n; i++) d[size + i] = v[i]; for (int i = size - 1; i >= 1; i--) { update(i); } } void set(int p, S x) { assert(0 <= p && p < _n); p += size; d[p] = x; for (int i = 1; i <= log; i++) update(p >> i); } S get(int p) const { assert(0 <= p && p < _n); return d[p + size]; } S prod(int l, int r) const { assert(0 <= l && l <= r && r <= _n); S sml = e(), smr = e(); l += size; r += size; while (l < r) { if (l & 1) sml = op(sml, d[l++]); if (r & 1) smr = op(d[--r], smr); l >>= 1; r >>= 1; } return op(sml, smr); } S all_prod() const { return d[1]; } template int max_right(int l) const { return max_right(l, [](S x) { return f(x); }); } template int max_right(int l, F f) const { assert(0 <= l && l <= _n); assert(f(e())); if (l == _n) return _n; l += size; S sm = e(); do { while (l % 2 == 0) l >>= 1; if (!f(op(sm, d[l]))) { while (l < size) { l = (2 * l); if (f(op(sm, d[l]))) { sm = op(sm, d[l]); l++; } } return l - size; } sm = op(sm, d[l]); l++; } while ((l & -l) != l); return _n; } template int min_left(int r) const { return min_left(r, [](S x) { return f(x); }); } template int min_left(int r, F f) const { assert(0 <= r && r <= _n); assert(f(e())); if (r == 0) return 0; r += size; S sm = e(); do { r--; while (r > 1 && (r % 2)) r >>= 1; if (!f(op(d[r], sm))) { while (r < size) { r = (2 * r + 1); if (f(op(d[r], sm))) { sm = op(d[r], sm); r--; } } return r + 1 - size; } sm = op(d[r], sm); } while ((r & -r) != r); return 0; } private: int _n, size, log; std::vector d; void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); } }; } // namespace atcoder using namespace atcoder; using ll = long long; using ld = long double; using pii = pair; using pll = pair; using pdd = pair; using vii = vector; using vll = vector; using vdd = vector; using vvii = vector>; using vvll = vector>; using vvdd = vector>; using vvvii = vector>>; using vvvll = vector>>; using vvvdd = vector>>; template using P = pair; template using V1 = vector; template using V2 = vector>; template using V3 = vector>>; template using pque = priority_queue, greater>; #define _overload3(_1, _2, _3, name, ...) name #define rep1(n) for (ll i = 0; i < (n); i++) #define rep2(i, n) for (ll i = 0; i < (n); i++) #define rep3(i, a, b) for (ll i = (a); i < (b); i++) #define rep(...) _overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__) #define rrep1(n) for (ll i = (n) - 1; i >= 0; i--) #define rrep2(i, n) for (ll i = (n) - 1; i >= 0; i--) #define rrep3(i, a, b) for (ll i = (b) - 1; i >= (a); i--) #define rrep(...) _overload3(__VA_ARGS__, rrep3, rrep2, rrep1)(__VA_ARGS__) #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define fi first #define se second #define pb push_back #define endl '\n' #define popcnt(x) __builtin_popcountll(x) #define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end()); #define IOS ios::sync_with_stdio(false); cin.tie(nullptr); const int inf = 1 << 30; const ll INF = 1ll << 60; const ld DINF = numeric_limits::infinity(); const ll mod = 1000000007; //const ll mod = 998244353; const ld EPS = 1e-9; const ld PI = 3.1415926535897932; const ll dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const ll dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; template bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } template T min(const vector &x) { return *min_element(all(x)); } template T max(const vector &x) { return *max_element(all(x)); } template ostream &operator<<(ostream &os, const pair &p) { return os << "(" << p.fi << ", " << p.se << ")"; } template ostream &operator<<(ostream &os, const vector &v) { os << "[ "; for (auto &z : v) os << z << " "; os << "]"; return os; } #ifdef _DEBUG #define show(x) cout << #x << " = " << x << endl; #else #define show(x) #endif ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; } ll rem(ll a, ll b) { return (a % b + b) % b; } // clang-format on // using mint = modint998244353; ll modpow(ll a, ll N, ll mod) { ll res = 1; // 例えば3=101(2)なので、下位bitから順に1ならa倍する while (N) { if (N & 1) res = res * a % mod; a = a * a % mod; N >>= 1; } return res; } int op(int a, int b) { return min(a, b); } int e() { return inf; } int main() { // IOS; int N, Q; cin >> N >> Q; V1> lrB(Q); rep(Q) { cin >> lrB[i].se.fi >> lrB[i].se.se >> lrB[i].fi; lrB[i].se.fi--, lrB[i].se.se--; } sort(all(lrB)); reverse(all(lrB)); segtree Seg(N); set Set; rep(i, N) Set.insert(i); rep(i, Q) { int l = lrB[i].se.fi, r = lrB[i].se.se, B = lrB[i].fi; while (1) { auto itr = Set.lower_bound(l); if (itr == Set.end()) break; if ((*itr) > r) break; show(*itr); show(B); Seg.set((*itr), B); show(Seg.get((*itr))); Set.erase(itr); } int m = Seg.prod(l, r + 1); if (m > B) { cout << -1 << endl; return 0; } } rep(i, N) { if (i) cout << " "; cout << Seg.get(i); } cout << endl; return 0; } /* メモ Bの大きい順にソートする */