#!/usr/bin/env python3 # from typing import * import sys import io import math import collections import decimal import itertools import bisect import heapq def input(): return sys.stdin.readline()[:-1] # sys.setrecursionlimit(1000000) # _INPUT = """5 3 # 1 3 1 # 3 5 3 # 4 5 4 # """ # sys.stdin = io.StringIO(_INPUT) INF = 10**10 class SegTree_Update_QRMin: def __init__(self, a) -> None: n = len(a) self.n0 = 1 << (n-1).bit_length() self.data = ([INF] * self.n0) + a + ([INF] * (self.n0-n)) for i in reversed(range(1, self.n0)): self.data[i] = min(self.data[i*2], self.data[i*2+1]) def query_rmin(self, l, r): l += self.n0 r += self.n0 s = INF while l < r: if l & 1: s = min(s, self.data[l]) l += 1 if r & 1: s = min(s, self.data[r-1]) r -= 1 l >>= 1 r >>= 1 return s def update(self, i, x): i += self.n0 self.data[i] = x while i > 0: i >>= 1 self.data[i] = min(self.data[i*2], self.data[i*2+1]) def get_value(self, i) -> int: return self.data[i+self.n0] def solve(N, Q, Query): Query.sort(key=lambda x: (x[1], x[0], x[2])) result = [10**9] * N k = 0 for i in range(N): if k < Q: l, r, b = Query[k] if l <= i <= r: result[i] = b k += 1 elif r < i: return [-1] seg_tree = SegTree_Update_QRMin(result) for l, r, b in Query: if seg_tree.query_rmin(l, r+1) != b: return [-1] return result N, Q = map(int, input().split()) Query = [] for _ in range(Q): l, r, b = map(int, input().split()) Query.append((l-1, r-1, b)) print(*solve(N, Q, Query))