import sys input = sys.stdin.readline from operator import itemgetter N,Q=map(int,input().split()) Queries=[list(map(int,input().split())) for i in range(Q)] Queries.sort(key=itemgetter(2)) seg_el=1<<((N+1).bit_length()) # Segment treeの台の要素数 SEG=[0]*(2*seg_el) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化 def getvalue(n,seg_el): # 一点の値を取得 i=n+seg_el ANS=0 ANS=max(SEG[i],ANS) i>>=1# 子ノードへ while i!=0: ANS=max(SEG[i],ANS) i>>=1 return ANS def updates(l,r,x): # 区間[l,r)のminを更新. L=l+seg_el R=r+seg_el while L>=1 R>>=1 for l,r,x in Queries: updates(l,r+1,x) A=[getvalue(i,seg_el) for i in range(1,N+1)] #print(*A) LEN = len(A) Sparse_table = [A] for i in range(LEN.bit_length()-1): j = 1<