N, Q = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(Q)] for i in range(Q): A[i][0] -= 1 INF = 2*10**9 opX = max opY = max UnitX = -INF UnitY = -INF act = max class LazySegmentTree(): def __init__(self, n, opX, opY, UnitX, UnitY, A=None): self.s = 2**(n).bit_length() self.size = 2*self.s self.node = [UnitX]*self.size self.lazy = [UnitY]*self.size if A: for i in range(n): self.node[self.s+i] = A[i] for i in range(self.s-1, -1, -1): self.node[i] = opX(self.node[2*i], self.node[2*i+1]) def propagation(self, i): h = i.bit_length()-1 for n in range(h, 0, -1): j = i >> n if self.lazy[j] != UnitY: self.node[j] = act(self.node[j], self.lazy[j]) self.lazy[2*j] = opY(self.lazy[2*j], self.lazy[j]) self.lazy[2*j+1] = opY(self.lazy[2*j+1], self.lazy[j]) self.lazy[j] = UnitY def recalculate(self, i): while i > 1: i >>= 1 x = act(self.node[2*i], self.lazy[2*i]) y = act(self.node[2*i+1], self.lazy[2*i+1]) self.node[i] = opX(x, y) def update_range(self, L, R, a): L += self.s R += self.s L0 = L//(L & -L) R0 = R//(R & -R) self.propagation(L0) self.propagation(R0) while L < R: if L & 1: self.lazy[L] = opY(self.lazy[L], a) L += 1 if R & 1: R -= 1 self.lazy[R] = opY(self.lazy[R], a) L >>= 1 R >>= 1 self.recalculate(L0) self.recalculate(R0) def get_range(self, L, R): vL, vR = UnitX, UnitX L += self.s R += self.s L0 = L//(L & -L) R0 = R//(R & -R) self.propagation(L0) self.propagation(R0) while L < R: if L & 1: vL = opX(vL, act(self.node[L], self.lazy[L])) L += 1 if R & 1: R -= 1 vR = opX(act(self.node[R], self.lazy[R]), vR) L >>= 1 R >>= 1 return opX(vL, vR) state = LazySegmentTree(N, max, max, -INF, -INF) for l, r, v in A: state.update_range(l, r, v) seq = [state.get_range(i, i+1) for i in range(N)] opX = min opY = min UnitX = INF UnitY = INF act = min solve = LazySegmentTree(N, min, min, INF, INF, seq) for l, r, v in A: if solve.get_range(l, r) != v: print(-1) break else: print(*seq)