import sys input = sys.stdin.readline from collections import defaultdict # ACL for pythonより # https://github.com/shakayami/ACL-for-python/blob/master/lazysegtree.py class lazy_segtree(): def update(self,k):self.d[k]=self.op(self.d[2*k],self.d[2*k+1]) def all_apply(self,k,f): self.d[k]=self.mapping(f,self.d[k]) if (k>i) self.d[p]=x for i in range(1,self.log+1):self.update(p>>i) def get(self,p): assert 0<=p and p>i) return self.d[p] def prod(self,l,r): #[l,r)の取得, [x,x)と取得すると単位元を返すので注意。 assert 0<=l and l<=r and r<=self.n if l==r:return self.e l+=self.size r+=self.size for i in range(self.log,0,-1): if (((l>>i)<>i) if (((r>>i)<>i) sml,smr=self.e,self.e while(l>=1 r>>=1 return self.op(sml,smr) def all_prod(self):return self.d[1] def apply_point(self,p,f): assert 0<=p and p>i) self.d[p]=self.mapping(f,self.d[p]) for i in range(1,self.log+1):self.update(p>>i) def apply(self,l,r,f): #[l,r)に作用 assert 0<=l and l<=r and r<=self.n if l==r:return l+=self.size r+=self.size for i in range(self.log,0,-1): if (((l>>i)<>i) if (((r>>i)<>i) l2,r2=l,r while(l>=1 r>>=1 l,r=l2,r2 for i in range(1,self.log+1): if (((l>>i)<>i) if (((r>>i)<>i) def max_right(self,l,g): assert 0<=l and l<=self.n assert g(self.e) if l==self.n:return self.n l+=self.size for i in range(self.log,0,-1):self.push(l>>i) sm=self.e while(1): while(i%2==0):l>>=1 if not(g(self.op(sm,self.d[l]))): while(l>i) sm=self.e while(1): r-=1 while(r>1 and (r%2)):r>>=1 if not(g(self.op(self.d[r],sm))): while(r>= 1 self._tree[i] = self._dot(self._tree[i << 1], self._tree[i << 1 | 1]) def add(self, i, v): self.update(i, self[i] + v) def sum(self, l, r): #これで[l,r)から取り出す。 l += self._n r += self._n l_val = r_val = self._unit while l < r: if l & 1: l_val = self._dot(l_val, self._tree[l]) l += 1 if r & 1: r -= 1 r_val = self._dot(self._tree[r], r_val) l >>= 1 r >>= 1 return self._dot(l_val, r_val) def main(): N,Q = map(int,input().split()); INF = pow(10,9) L = defaultdict(list) R = defaultdict(list) comp = set([]) query = [] for i in range(Q): l,r,b = map(int,input().split()) l -= 1; r -= 1 L[l].append(b) R[r].append(b) comp.add(b) query.append((l,r,b)) query.sort(key = lambda x:x[2]) G = lazy_segtree([INF for i in range(N)],operate,INF,mapping,composition,(1,0)) for l,r,b in query: G.apply(l,r+1,(0,b)) ans = [INF]*N for i in range(N): ans[i] = G.get(i) #print(*ans) Tree = SegmentTree(ans,min,INF) for l,r,b in query: mx = Tree.sum(l,r+1) if mx != b: print(-1) break else: print(*ans) if __name__ == '__main__': main()