#define _USE_MATH_DEFINES #include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constexpr int MOD = 1000000007; // constexpr int MOD = 998244353; constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1}; template inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; } template inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << fixed << setprecision(20); } } iosetup; template struct SparseTable { using Fn = std::function; SparseTable() {} SparseTable(const std::vector &a, Fn fn) { init(a, fn); } void init(const std::vector &a, Fn fn_) { is_built = true; fn = fn_; int n = a.size(), table_h = 0; lg.assign(n + 1, 0); for (int i = 2; i <= n; ++i) lg[i] = lg[i >> 1] + 1; while ((1 << table_h) <= n) ++table_h; dat.assign(table_h, std::vector(n)); for (int j = 0; j < n; ++j) dat[0][j] = a[j]; for (int i = 1; i < table_h; ++i) for (int j = 0; j + (1 << i) <= n; ++j) { dat[i][j] = fn(dat[i - 1][j], dat[i - 1][j + (1 << (i - 1))]); } } Band query(int left, int right) const { assert(is_built && left < right); int h = lg[right - left]; return fn(dat[h][left], dat[h][right - (1 << h)]); } private: bool is_built = false; Fn fn; std::vector lg; std::vector> dat; }; int main() { int n, q; cin >> n >> q; vector l(q), r(q), b(q); REP(i, q) cin >> l[i] >> r[i] >> b[i], --l[i], --r[i]; vector ord(q); iota(ALL(ord), 0); sort(ALL(ord), [&](int l, int r) -> bool { return b[l] > b[r]; }); vector a(n, 1); set s; REP(i, n) s.emplace(i); for (int i : ord) { for (auto it = s.lower_bound(l[i]); it != s.end() && *it <= r[i]; it = s.erase(it)) { a[*it] = b[i]; } } SparseTable sparse_table(a, [](int a, int b) -> int { return min(a, b); }); REP(i, q) { if (sparse_table.query(l[i], r[i] + 1) != b[i]) { cout << "-1\n"; return 0; } } REP(i, n) cout << a[i] << " \n"[i + 1 == n]; return 0; }