#include using namespace std; #define all(v) v.begin(), v.end() int main() { int n, q; cin >> n >> q; vector> query(q); for (int i = 0; i < q; i++) { int a, b, c; cin >> a >> b >> c; a--, b--; query[i] = {c, a, b}; } sort(all(query)); reverse(all(query)); int before = -1; vector tmp(n); iota(all(tmp), 0); set unused(all(tmp)), used_i; vector ans(n); for (auto [b, l, r] : query) { if (b != before) { before = b; used_i.clear(); } auto itr = unused.lower_bound(l); if (itr == unused.end() || *itr > r) // 更新可能なものがない { auto itr_i = used_i.lower_bound(l); if (itr_i == used_i.end() || *itr_i > r) { cout << -1 << endl; return 0; } } else // 更新可能なものがある { while (itr != unused.end() && *itr <= r) { ans[*itr] = b; used_i.insert(*itr); itr = unused.erase(itr); } } } for (auto i : unused) ans[i] = int(1e9); for (int i = 0; i < n; i++) cout << ans[i] << ' '; return 0; }