N,Q = map(int, input().split()) L = [] inf = 10**9 for _ in range(Q): l,r,b=map(int, input().split()) L.append([l-1,r-1,b]) L = sorted(L, key=lambda x: x[1]) L = sorted(L, key=lambda x: x[2]) L = sorted(L, key=lambda x: x[0]) ANS = [inf]*N for l in L: l,r,b = l[0],l[1],l[2] for i in range(l,r+1): if ANS[i]==b: break if ANS[i]