#include "bits/stdc++.h" #include using namespace std; using namespace atcoder; using ll = long long; using vl = vector; using pl = pair; struct edge {long long to;long long cost;edge(long long t,long long c):to(t),cost(c){}}; using Graph = vector>; using WGraph = vector>; constexpr int dx[8]{1,0,-1,0,1,1,-1,-1}; constexpr int dy[8]{0,1,0,-1,1,-1,1,-1}; #define rep(i, n) for(long long (i) = 0; (i) < (n); (i)++) #define reps(i, a, b) for(long long (i) = (a); (i) < (b); (i)++) #define rrep(i, a, b) for(long long (i) = (a); (i) >= (b); (i)--) #define all(v) (v).begin(), (v).end() #define pb push_back #define V vector constexpr long long MOD1 = 1000000007; constexpr long long MOD9 = 998244353; constexpr long long INF = 1000000000; constexpr long long LL_MAX = std::numeric_limits::max(); long long safe_mod(long long n, long long m){if(n >= 0) {return n % m;} else return (n%m + m)%m;} long long div_ceil(long long a, long long b){return (a + b - 1) / b;} long long pw(long long x,long long n) {ll ret=1;while(n>0){if(n&1){ret=ret*x;}if(n>>=1){x=x*x;}}return ret;} template T SUM(const vector &v){T ret{};return(accumulate(v.begin(), v.end(), ret));} template T MAX(const vector &v){return *max_element(v.begin(), v.end());} template T MIN(const vector &v){return *min_element(v.begin(), v.end());} template T pwmod(T x, long long n, long long m) {T ret=1;while(n>0){if(n&1)ret=ret*x%m;x=x*x%m;n>>=1;}return ret%m;} template void rsort(vector &v) {sort(v.begin(), v.end(), greater());} template bool chmax(T &a, const T& b) {if(a bool chmin(T &a, const T& b) {if(a>b){a=b;return true;}return false;} template pair mp(const T &a, const S &b){return make_pair(a, b);} template void uniquify(vector &v){sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());} template ostream&operator<<(ostream&os,const pair&p){os<<"("< ostream&operator<<(ostream&os,const map&ma){for(auto [a,b]:ma){os<<"("< ostream &operator<<(ostream&os,const set&s){os<<"{";for(auto c:s)os< ostream &operator<<(ostream&os,const vector&v){os<<"[";for(int i=0;i vector compress(vector &a){ int n = a.size(); vector ret(n); vector temp = a; sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); for(int i = 0; i < n; i++) ret[i] = lower_bound(a.begin(), a.end(), temp[i]) - a.begin(); return ret; } //#define ONLINE_JUDGE #ifdef ONLINE_JUDGE #define dump(x) true #else #define dump(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl #endif ll op(ll a, ll b){return min(a, b);} ll e(){return INF;} void solve(){ ll n, q; cin >> n >> q; V L(n+1), R(n+1); V> Query(q); rep(i, q){ ll l, r, b; cin >> l >> r >> b; l--; L[l].pb(b); R[r].pb(b); Query[i] = {l, r, b}; } multiset rest; segtree seg(n); rest.insert(1); rep(i, n){ for(ll t : R[i]){ auto iter = rest.find(t); rest.erase(iter); } for(ll t : L[i]) rest.insert(t); seg.set(i, *rest.rbegin()); } rep(i, q){ auto [l, r, b] = Query[i]; if(seg.prod(l, r) != b){ cout << -1 << '\n'; return; } } rep(i, n){ cout << seg.get(i) << ' '; } cout << '\n'; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << std::fixed << std::setprecision(15); solve(); return 0; }