import sys import math sys.setrecursionlimit(10**7) class lazysegki(): DEFAULT = { 'min': 1 << 60, 'max': -(1 << 60), } FUNC = { 'min': min, 'max': max, } def __init__(self,N,ls,mode='min'): #葉の数N,要素ls self.default = self.DEFAULT[mode] self.func = self.FUNC[mode] self.N = N self.K = (N-1).bit_length() self.N0 = 1 << self.K self.dat = [self.default]*(2**(self.K+1)) #全体の配列を用意(maxなら-inf,minなら+infで未構築を表現)  self.lazy = [None]*(2**(self.K+1)) #遅延評価 for i in range(self.N): #葉の構築 self.dat[2**self.K+i] = ls[i] self.build() def build(self): for j in range(self.N0-1,0,-1): self.dat[j] = self.func(self.dat[j<<1],self.dat[j<<1|1]) #親が持つ条件 def leafvalue(self,x): #x番目の値を出力 return self.query(x,x+1) def gindex(self,l, r): #伝播するインデックス列挙 L = l + self.N0; R = r + self.N0 lm = (L // (L & -L)) >> 1 rm = (R // (R & -R)) >> 1 lsindex = [] while L < R: if R <= rm: lsindex.append(R) if L <= lm: lsindex.append(L) L >>= 1; R >>= 1 while L: lsindex.append(L) L >>= 1 return lsindex def propagates(self,ids): for i in reversed(ids): v = self.lazy[i] if v is None: continue self.lazy[i<<1] = self.dat[i<<1] = self.lazy[i<<1|1] = self.dat[i<<1|1] = v self.lazy[i] = None def update_replace(self,l, r, x): ids = self.gindex(l, r) # 1. トップダウンにlazyの値を伝搬 self.propagates(ids) # 2. 区間[l, r)のdata, lazyの値を更新 L = self.N0 + l; R = self.N0 + r while L < R: if R & 1: R -= 1 self.lazy[R] = self.dat[R] = x if L & 1: self.lazy[L] = self.dat[L] = x L += 1 L >>= 1; R >>= 1 # 3. 伝搬させた区間について、ボトムアップにself.dataの値を伝搬する #print(ids) for i in ids: self.dat[i] = self.func(self.dat[i<<1],self.dat[i<<1|1]) def query(self,l, r): self.propagates(self.gindex(l, r)) L = self.N0 + l R = self.N0 + r vL = self.default vR = self.default while L < R: if L & 1: vL = self.func(vL,self.dat[L]) L += 1 if R & 1: R -= 1 vR = self.func(self.dat[R],vR) L >>= 1 R >>= 1 return self.func(vL,vR) N,Q = map(int,input().split()) lsQ = [] for i in range(Q): l,r,B = map(int,input().split()) lsQ.append((B,l-1,r)) lsQ.sort() ll = [10**9]*(N) LSG = lazysegki(N, ll) for B,l,r in lsQ: LSG.update_replace(l, r, B) for B,l,r in lsQ: v = LSG.query(l, r) if B != v: print(-1) break else: lsans = [LSG.leafvalue(i) for i in range(N)] print(*lsans)