Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event.

As for you, you're just a simple peasant. There's no surprise that you slept in this morning and were late for the tournament (it was a weekend, after all). Now you are really curious about the results of the tournament. This time the tournament in Berland went as follows:  There are n knights participating in the tournament. Each knight was assigned his unique number — an integer from 1 to n.  The tournament consisted of m fights, in the i-th fight the knights that were still in the game with numbers at least l_{i} and at most r_{i} have fought for the right to continue taking part in the tournament.  After the i-th fight among all participants of the fight only one knight won — the knight number x_{i}, he continued participating in the tournament. Other knights left the tournament.  The winner of the last (the m-th) fight (the knight number x_{m}) became the winner of the tournament. 

You fished out all the information about the fights from your friends. Now for each knight you want to know the name of the knight he was conquered by. We think that the knight number b was conquered by the knight number a, if there was a fight with both of these knights present and the winner was the knight number a.

Write the code that calculates for each knight, the name of the knight that beat him.


-----Input-----

The first line contains two integers n, m (2 ≤ n ≤ 3·10^5; 1 ≤ m ≤ 3·10^5) — the number of knights and the number of fights. Each of the following m lines contains three integers l_{i}, r_{i}, x_{i} (1 ≤ l_{i} < r_{i} ≤ n; l_{i} ≤ x_{i} ≤ r_{i}) — the description of the i-th fight.

It is guaranteed that the input is correct and matches the problem statement. It is guaranteed that at least two knights took part in each battle.


-----Output-----

Print n integers. If the i-th knight lost, then the i-th number should equal the number of the knight that beat the knight number i. If the i-th knight is the winner, then the i-th number must equal 0.


-----Examples-----
Input
4 3
1 2 1
1 3 3
1 4 4

Output
3 1 4 0 
Input
8 4
3 5 4
3 7 6
2 8 8
1 8 1

Output
0 8 4 6 4 8 6 1 


-----Note-----

Consider the first test case. Knights 1 and 2 fought the first fight and knight 1 won. Knights 1 and 3 fought the second fight and knight 3 won. The last fight was between knights 3 and 4, knight 4 won.

Difficulty: competition

Starter code:

Solutions:
n, m = map(int, input().split())
p, d = [0] * (n + 2), [0] * (n + 2)
for i in range(m):
    l, r, x = map(int, input().split())
    while l < x:
        if d[l]:
            k = d[l]
            d[l] = x - l
            l += k
        else:
            d[l], p[l] = x - l, x
            l += 1
    l += 1
    r += 1
    while d[r]: r += d[r]
    while l < r:
        if d[l]:
            k = d[l]
            d[l] = r - l
            l += k
        else:
            d[l], p[l] = r - l, x
            l += 1
print(' '.join(map(str, p[1: -1])))

n, m = map(int, input().split())
p, d = [0] * (n + 2), list(range(1, n + 3))
for i in range(m):
    l, r, x = map(int, input().split())
    while l < x:
        if p[l]: 
            k = d[l]
            d[l] = x
            l = k
        else: 
            d[l], p[l] = x, x
            l += 1
    l += 1
    r += 1
    while p[r]: r = d[r]
    while l < r:
        if p[l]: 
            k = d[l]
            d[l] = r
            l = k
        else:
            d[l], p[l] = r, x
            l += 1
print(' '.join(map(str, p[1: -1])))

def main():
    mode="filee"
    if mode=="file":f=open("test.txt","r")
    get = lambda :[int(x) for x in (f.readline() if mode=="file" else input()).split()]
    [n,m]=get()
    k=[0 for i in range(n)]
    g=[z+1 for z in range(n+1)]
    for i in range(m):
        [m,n,p]=get()
        j=m-1
        while j<=n-1:
            if k[j]==0 and j!=p-1:k[j]=p
            tmp=g[j]
            if j<p-1:
                g[j]=p-1
            else:
                g[j]=n
            #print(j+1,tmp,g[j])
            j=tmp
    for i in k:
        print (i,end=' ')

    if mode=="file":f.close()


def __starting_point():
    main()
#copied...

__starting_point()

def main():
    n, m = list(map(int, input().split()))
    alive, winner = list(range(1, n + 3)), [0] * (n + 2)
    for _ in range(m):
        l, r, x = list(map(int, input().split()))
        while l < x:
            if winner[l]:
                alive[l], l = x, alive[l]
            else:
                alive[l] = winner[l] = x
                l += 1
        l += 1
        r += 1
        while winner[r]:
            r = alive[r]
        while l < r:
            if winner[l]:
                alive[l], l = r, alive[l]
            else:
                alive[l], winner[l] = r, x
                l += 1
    print(' '.join(map(str, winner[1: -1])))


def __starting_point():
    main()

__starting_point()

def main():
    n, m = list(map(int, input().split()))
    alive, winner = list(range(1, n + 3)), [0] * (n + 2)
    for _ in range(m):
        l, r, x = list(map(int, input().split()))
        while l < x:
            if winner[l]:
                alive[l], l = x, alive[l]
            else:
                alive[l] = winner[l] = x
                l += 1
        l += 1
        r += 1
        while l < r:
            if winner[l]:
                alive[l], l = r, alive[l]
            else:
                alive[l], winner[l] = r, x
                l += 1
    print(' '.join(map(str, winner[1: -1])))


def __starting_point():
    main()

__starting_point()

n, m = list(map(int, input().split()))
p, d = [0] * (n + 2), list(range(1, n + 3))
for i in range(m):
    l, r, x = list(map(int, input().split()))
    while l < x:
        if p[l]: 
            k = d[l]
            d[l] = x
            l = k
        else: 
            d[l], p[l] = x, x
            l += 1
    l += 1
    r += 1
    while p[r]: r = d[r]
    while l < r:
        if p[l]: 
            k = d[l]
            d[l] = r
            l = k
        else:
            d[l], p[l] = r, x
            l += 1
print(' '.join(map(str, p[1: -1])))


import os
n,m = list(map(int,input().split()))

parent = list(range(0,n+1))
answer = list(range(0,n))

def getParent(x):
    while parent[x] != x:
        x = parent[x]
        parent[x] = parent[parent[x]]
    return parent[x]


for i in range(m):
    l, r, x = list(map(int,input().split()))
    cnt = getParent(l-1)
    while cnt <= (r-1):
        if cnt == (x-1):
            cnt = cnt + 1
        else:
            parent[cnt] = cnt+1
            answer[cnt] = x-1
        cnt = getParent(cnt)
    # print(parent)
    # print(answer)
c = 0
s = ""
for i in answer:
    if c == i:
        s += "0 "
    else:
        s += str(i+1) + " "
    c = c+1
os.write(1,str.encode(s))





n, m = map(int, input().split())

p, d = [0] * (n + 2), list(range(1, n + 3))

for i in range(m):

    l, r, x = map(int, input().split())

    while l < x:

        if p[l]: 

            k = d[l]

            d[l] = x

            l = k

        else: 

            d[l], p[l] = x, x

            l += 1

    l += 1

    r += 1

    while p[r]: r = d[r]

    while l < r:

        if p[l]: 

            k = d[l]

            d[l] = r

            l = k

        else:

            d[l], p[l] = r, x

            l += 1

print(' '.join(map(str, p[1: -1])))

def main():
    n, m = list(map(int, input().split()))
    alive, winner = list(range(1, n + 3)), [0] * (n + 2)
    for _ in range(m):
        l, r, x = list(map(int, input().split()))
        while l < x:
            if winner[l]:
                alive[l], l = x, alive[l]
            else:
                alive[l] = winner[l] = x
                l += 1
        l += 1
        r += 1
        while winner[r]:
            r = alive[r]
        while l < r:
            if winner[l]:
                alive[l], l = r, alive[l]
            else:
                alive[l], winner[l] = r, x
                l += 1
    print(' '.join(map(str, winner[1: -1])))


def __starting_point():
    main()

__starting_point()

nKnights, nFights = map(int,input().split())
anext = [i + 1 for i in range(nKnights + 1)]
result = [0] * nKnights
for _ in range(nFights):
    l, r, x = map(int,input().split())
    i = l
    while i <= r:
        if result[i-1]==0 and i!=x:
            result[i-1] = x
        temp = anext[i]
        if i < x:
            anext[i] = x
        else:
            anext[i] = r + 1
        i = temp
print(*result)

def prog():
    n,m = map(int,input().split())
    res,anext = [0]*n,[i+1 for i in range(n+2)]
    from sys import stdin
    for _ in range(m):
        l,r,x = map(int,stdin.readline().split())
        i=l
        while i<=r:
            if res[i-1]==0 and i!=x:
                res[i-1]=x
            save = anext[i]
            if i<x:
                anext[i]=x
            else:
                anext[i]=r+1
            i=save
    print(*res)
prog()

def prog():
    n,m = map(int,input().split())
    res,anext = [0]*n,[i+1 for i in range(n+2)]
    from sys import stdin
    for _ in range(m):
        l,r,x = map(int,stdin.readline().split())
        i=l
        while i<=r:
            if res[i-1]==0 and i!=x:
                res[i-1]=x
            save = anext[i]
            if i<x:
                anext[i]=x
            else:
                anext[i]=r+1
            i=save
    print(*res)
prog()

def ans():
    n,m = list(map(int,input().split()))
    res,alive = [0]*n,[(i+1) for i in range(n+2)]
    from sys import stdin
    for _ in range(m):
        l,r,x = list(map(int,stdin.readline().split()))
        i=l
        while i<=r:
            if res[i-1]==0 and i!=x:
                res[i-1] = x
            temp = alive[i]
            if i < x:
                alive[i] = x
            else:
                alive[i] = r+1
            i = temp
    print(*res)
ans()


import sys

class SegmTree():
    def __init__(self, array=None, size=None):
        if array is not None:
            size = len(array)
        N = 1
        while N < size:
            N <<= 1
        self.N = N
        self.tree = [0] * (2*self.N)
        if array is not None:
            for i in range(size):
                self.tree[i+self.N] = array[i]
            self.build()

    def build(self):
        for i in range(self.N - 1, 0, -1):
            self.tree[i] = self.tree[i<<1] + self.tree[i<<1|1]

    def add(self, i, value=1):
        i += self.N
        while i > 0:
            self.tree[i] += value
            i >>= 1    
    
    def find_nonzeros(self, l, r):
        N = self.N
        l += N
        r += N
        cand = []
        while l < r:
            if l & 1:
                if self.tree[l]:
                    cand.append(l)
                l += 1
            if r & 1:
                r -= 1
                if self.tree[r]:
                    cand.append(r)
            l >>= 1
            r >>= 1
        ans = []
        while cand:
            i = cand.pop()
            if i < N:
                i <<= 1
                if self.tree[i]:
                    cand.append(i)
                if self.tree[i|1]:
                    cand.append(i|1)
            else:
                ans.append(i - N)
        return ans

# inf = open('input.txt', 'r')
# reader = (line.rstrip() for line in inf)
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__

n, m = list(map(int, input().split()))
st = SegmTree([1]*n)
ans = [0] * n
for _ in range(m):
    l, r, x = list(map(int, input().split()))
    l -= 1
    x -= 1
    for i in st.find_nonzeros(l, r):
        if i != x:
            ans[i] = x + 1
            st.add(i, -1)
print(*ans)
    
# inf.close()


#!/usr/bin/env python3
import os
import sys
from atexit import register
from io import StringIO

# Buffered output, at least 2x faster.
sys.stdout = StringIO()
register(lambda: os.write(1, sys.stdout.getvalue().encode()))

###############################################################################
import math
###############################################################################
n,m = [int(k) for k in input().split()]
t = [0] * (4*n)

def update(x, l, r, v, tl, tr):
    if r < l: return
    if t[v] != 0: return
    if l == tl and r == tr:
        t[v] = x
    else:
        tm = (tl+tr)>>1
        update(x, l, min(tm, r), 2*v, tl, tm)
        update(x, max(tm+1, l), r, 2*v+1, tm+1, tr)

def query(i):
    v = 1
    tl = 1
    tr = n
    while tl != tr:
        tm = (tl+tr)>>1
        if i <= tm:
            v = v<<1
            tr = tm
        else:
            v = (v<<1)+1
            tl = tm+1
    k = 0
    while v != 0:
       k = k or t[v]
       v = v >> 1
    return k

for _ in range(m):
    l,r,x = [int(k) for k in input().split()]
    update(x, l, x-1, 1, 1, n)
    update(x, x+1, r, 1, 1, n)
print(' '.join([str(query(k)) for k in range(1, n+1)]))


# -*- coding: utf-8 -*-

# Baqir Khan
# Software Engineer (Backend)

from sys import stdin

inp = stdin.readline

n, m = list(map(int, inp().split()))
ans = [0] * (n + 1)
alive = [(i + 1) for i in range(n + 2)]

while m:
    m -= 1
    l, r, x = list(map(int, inp().split()))
    i = l
    while i <= r:
        if ans[i] == 0 and i != x:
            ans[i] = x
        temp = alive[i]
        if i < x:
            alive[i] = x
        else:
            alive[i] = r + 1
        i = temp

print(*ans[1:])


from sys import stdin
input=lambda : stdin.readline().strip()
from math import ceil,sqrt,factorial,gcd
n,m=map(int,input().split())
ans=[0 for i in range(n)]
nextl=[i+1 for i in range(n+2)]
for j in range(m):
	l,r,x=map(int,input().split())
	i=l
	while i<=r:
		if ans[i-1]==0 and i!=x:
			ans[i-1]=x
		a=nextl[i]
		if i<x:
			nextl[i]=x
		else:
			nextl[i]=r+1
		i=a
print(*ans)

#------------------------------warmup----------------------------
import os
import sys
from io import BytesIO, IOBase
 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
#-------------------game starts now----------------------------------------------------
import bisect 
n,m=list(map(int,input().split()))
nex=[i+1 for i in range(n)]
ans=[0]*n
for i in range(m):
    l,r,x=list(map(int,input().split()))
    j=l-1
    while(j<r):
        if ans[j]==0 and j!=x-1:
            ans[j]=x
        a=nex[j]
        if j<x-1:
            nex[j]=x-1
        else:
            nex[j]=r
        j=a
print(*ans)
    


import sys
input = sys.stdin.readline

def inint():
    return(int(input()))

def inlst():
    return(list(map(int,input().split())))

# returns a List of Characters, which is easier to use in Python as Strings are Immutable
def instr():
    s = input()
    return(list(s[:len(s) - 1]))

def invar():
    return(list(map(int,input().split())))

############ ---- Input function template ---- ############

def isOdd(num):
  return (num & 1) == 1

n, m = invar()

# build function
tree = [{'round_num':m, 'winner':-1} for _ in range(2*n+1, 0, -1)]

def modify(left, right, pair):
  left += n
  right += n
  while left <= right:
    if isOdd(left):
      tree[left] = pair

    if not isOdd(right):
      tree[right] = pair

    left = int((left+1)/2)
    right = int((right-1)/2)


def query(pos):
  pos += n
  min = 1000000
  winner = -1
  while pos > 0:
    if tree[pos]['round_num'] < min:
      winner = tree[pos]['winner']
      min = tree[pos]['round_num']

    pos >>= 1

  return winner + 1 if winner > -1 else 0

rounds = []
for _ in range(m):
  li, ri, xi = invar()
  rounds.append({'left':li-1, 'right':ri-1, 'winner':xi-1})

for idx in range(m-1, -1, -1):
  round = rounds[idx]
  if round['winner'] > 0: modify(round['left'], round['winner']-1, {'round_num': idx, 'winner':round['winner']})
  if round['winner'] < n: modify(round['winner']+1, round['right'], {'round_num': idx, 'winner':round['winner']})

print(*[query(i) for i in range(n)])


import sys
input = sys.stdin.readline

def inint():
    return(int(input()))

def inlst():
    return(list(map(int,input().split())))

# returns a List of Characters, which is easier to use in Python as Strings are Immutable
def instr():
    s = input()
    return(list(s[:len(s) - 1]))

def invar():
    return(list(map(int,input().split())))

############ ---- Input function template ---- ############

def isOdd(num):
  return (num & 1) == 1

n, m = invar()

# build function
# 2n+1 is needed as 1-index would be used
tree = [{'round_num':m, 'winner':-1} for _ in range(2*n+1, 0, -1)]

def modify(left, right, pair):
  left += n
  right += n
  while left <= right:
    if isOdd(left):
      tree[left] = pair

    if not isOdd(right):
      tree[right] = pair

    left = int((left+1)/2)
    right = int((right-1)/2)


def query(pos):
  pos += n
  min = 1000000
  winner = -1
  
  while pos > 0:
    if tree[pos]['round_num'] < min:
      winner = tree[pos]['winner']
      min = tree[pos]['round_num']
    pos >>= 1

  return winner if winner > -1 else 0

rounds = []
for _ in range(m):
  li, ri, xi = invar()
  rounds.append({'left':li, 'right':ri, 'winner':xi})

# iterating input in reverse order
for idx in range(m-1, -1, -1):
  round = rounds[idx]
  # update winner for all the knights in tournament. except for winner itself
  if round['winner'] > 0: modify(round['left'], round['winner']-1, {'round_num': idx, 'winner':round['winner']})
  if round['winner'] < n: modify(round['winner']+1, round['right'], {'round_num': idx, 'winner':round['winner']})

print(*[query(i) for i in range(1, n+1)])


#!/usr/bin/env python
#pyrival orz
import os
import sys
from io import BytesIO, IOBase

"""
    for _ in range(int(input())):
    n,m=map(int,input().split())
    n=int(input())
    a = [int(x) for x in input().split()]
"""

class SortedList:
    def __init__(self, iterable=[], _load=200):
        """Initialize sorted list instance."""
        values = sorted(iterable)
        self._len = _len = len(values)
        self._load = _load
        self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
        self._list_lens = [len(_list) for _list in _lists]
        self._mins = [_list[0] for _list in _lists]
        self._fen_tree = []
        self._rebuild = True

    def _fen_build(self):
        """Build a fenwick tree instance."""
        self._fen_tree[:] = self._list_lens
        _fen_tree = self._fen_tree
        for i in range(len(_fen_tree)):
            if i | i + 1 < len(_fen_tree):
                _fen_tree[i | i + 1] += _fen_tree[i]
        self._rebuild = False

    def _fen_update(self, index, value):
        """Update `fen_tree[index] += value`."""
        if not self._rebuild:
            _fen_tree = self._fen_tree
            while index < len(_fen_tree):
                _fen_tree[index] += value
                index |= index + 1

    def _fen_query(self, end):
        """Return `sum(_fen_tree[:end])`."""
        if self._rebuild:
            self._fen_build()

        _fen_tree = self._fen_tree
        x = 0
        while end:
            x += _fen_tree[end - 1]
            end &= end - 1
        return x

    def _fen_findkth(self, k):
        """Return a pair of (the largest `idx` such that `sum(_fen_tree[:idx]) <= k`, `k - sum(_fen_tree[:idx])`)."""
        _list_lens = self._list_lens
        if k < _list_lens[0]:
            return 0, k
        if k >= self._len - _list_lens[-1]:
            return len(_list_lens) - 1, k + _list_lens[-1] - self._len
        if self._rebuild:
            self._fen_build()

        _fen_tree = self._fen_tree
        idx = -1
        for d in reversed(range(len(_fen_tree).bit_length())):
            right_idx = idx + (1 << d)
            if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
                idx = right_idx
                k -= _fen_tree[idx]
        return idx + 1, k

    def _delete(self, pos, idx):
        """Delete value at the given `(pos, idx)`."""
        _lists = self._lists
        _mins = self._mins
        _list_lens = self._list_lens

        self._len -= 1
        self._fen_update(pos, -1)
        del _lists[pos][idx]
        _list_lens[pos] -= 1

        if _list_lens[pos]:
            _mins[pos] = _lists[pos][0]
        else:
            del _lists[pos]
            del _list_lens[pos]
            del _mins[pos]
            self._rebuild = True

    def _loc_left(self, value):
        """Return an index pair that corresponds to the first position of `value` in the sorted list."""
        if not self._len:
            return 0, 0

        _lists = self._lists
        _mins = self._mins

        lo, pos = -1, len(_lists) - 1
        while lo + 1 < pos:
            mi = (lo + pos) >> 1
            if value <= _mins[mi]:
                pos = mi
            else:
                lo = mi

        if pos and value <= _lists[pos - 1][-1]:
            pos -= 1

        _list = _lists[pos]
        lo, idx = -1, len(_list)
        while lo + 1 < idx:
            mi = (lo + idx) >> 1
            if value <= _list[mi]:
                idx = mi
            else:
                lo = mi

        return pos, idx

    def _loc_right(self, value):
        """Return an index pair that corresponds to the last position of `value` in the sorted list."""
        if not self._len:
            return 0, 0

        _lists = self._lists
        _mins = self._mins

        pos, hi = 0, len(_lists)
        while pos + 1 < hi:
            mi = (pos + hi) >> 1
            if value < _mins[mi]:
                hi = mi
            else:
                pos = mi

        _list = _lists[pos]
        lo, idx = -1, len(_list)
        while lo + 1 < idx:
            mi = (lo + idx) >> 1
            if value < _list[mi]:
                idx = mi
            else:
                lo = mi

        return pos, idx

    def add(self, value):
        """Add `value` to sorted list."""
        _load = self._load
        _lists = self._lists
        _mins = self._mins
        _list_lens = self._list_lens

        self._len += 1
        if _lists:
            pos, idx = self._loc_right(value)
            self._fen_update(pos, 1)
            _list = _lists[pos]
            _list.insert(idx, value)
            _list_lens[pos] += 1
            _mins[pos] = _list[0]
            if _load + _load < len(_list):
                _lists.insert(pos + 1, _list[_load:])
                _list_lens.insert(pos + 1, len(_list) - _load)
                _mins.insert(pos + 1, _list[_load])
                _list_lens[pos] = _load
                del _list[_load:]
                self._rebuild = True
        else:
            _lists.append([value])
            _mins.append(value)
            _list_lens.append(1)
            self._rebuild = True

    def discard(self, value):
        """Remove `value` from sorted list if it is a member."""
        _lists = self._lists
        if _lists:
            pos, idx = self._loc_right(value)
            if idx and _lists[pos][idx - 1] == value:
                self._delete(pos, idx - 1)

    def remove(self, value):
        """Remove `value` from sorted list; `value` must be a member."""
        _len = self._len
        self.discard(value)
        if _len == self._len:
            raise ValueError('{0!r} not in list'.format(value))

    def pop(self, index=-1):
        """Remove and return value at `index` in sorted list."""
        pos, idx = self._fen_findkth(self._len + index if index < 0 else index)
        value = self._lists[pos][idx]
        self._delete(pos, idx)
        return value

    def bisect_left(self, value):
        """Return the first index to insert `value` in the sorted list."""
        pos, idx = self._loc_left(value)
        return self._fen_query(pos) + idx

    def bisect_right(self, value):
        """Return the last index to insert `value` in the sorted list."""
        pos, idx = self._loc_right(value)
        return self._fen_query(pos) + idx

    def count(self, value):
        """Return number of occurrences of `value` in the sorted list."""
        return self.bisect_right(value) - self.bisect_left(value)

    def __len__(self):
        """Return the size of the sorted list."""
        return self._len

    def __getitem__(self, index):
        """Lookup value at `index` in sorted list."""
        pos, idx = self._fen_findkth(self._len + index if index < 0 else index)
        return self._lists[pos][idx]

    def __delitem__(self, index):
        """Remove value at `index` from sorted list."""
        pos, idx = self._fen_findkth(self._len + index if index < 0 else index)
        self._delete(pos, idx)

    def __contains__(self, value):
        """Return true if `value` is an element of the sorted list."""
        _lists = self._lists
        if _lists:
            pos, idx = self._loc_left(value)
            return idx < len(_lists[pos]) and _lists[pos][idx] == value
        return False

    def __iter__(self):
        """Return an iterator over the sorted list."""
        return (value for _list in self._lists for value in _list)

    def __reversed__(self):
        """Return a reverse iterator over the sorted list."""
        return (value for _list in reversed(self._lists) for value in reversed(_list))

    def __repr__(self):
        """Return string representation of sorted list."""
        return 'SortedList({0})'.format(list(self))

def main():
    n,m=map(int,input().split())
    ans=[0]*n
    st=SortedList([i for i in range(n)])
    for _ in range(m):
        l,r,x=map(int,input().split())
        idx=st.bisect_left(l-1)
        # print(l,r,x)
        while idx<len(st):
            cur=st[idx]
            if cur>=r:
                break
            # print(cur)
            ans[cur]=x
            st.discard(cur)
        ans[x-1]=0
        st.add(x-1)
    print(*ans)
# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

def __starting_point():
    main()
__starting_point()

from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

class SegTree:
	def __init__(self, size):
		self.n = size
		self.T = [[INF, INF] for _ in range(4*self.n)]

	def _update_range(self, v, tl, tr, l, r, val):
		if l > r or tl > tr: return
		# print(f"l, r = {l, r}, tl, tr = {tl, tr}")
		if l == tl and r == tr:
			# self.T[v].append(val)
			if self.T[v] == [INF, INF]:
				self.T[v] = val
		else:
			mid = (tl + tr)//2
			self._update_range(2*v, tl, mid, l, min(r, mid), val)
			self._update_range(2*v+1, mid+1, tr, max(l, mid+1), r, val)

	def update_range(self, l, r, val):
		self._update_range(1, 0, self.n-1, l, r, val)


	def qry(self, index):
		return self._qry(1, 0, self.n-1, index)

	def _qry(self, v, tl, tr, index):
		if tl == tr:
			if self.T[v]:
				return self.T[v]
			else:
				return (INF, INF)
		else:
			mid = (tl + tr)//2
			curr_x, curr_time = INF, INF
			if self.T[v]:
			 	curr_x, curr_time = self.T[v]
			if index <= mid:
				prev_x, prev_time = self._qry(2*v, tl, mid, index)
			else:
				prev_x, prev_time = self._qry(2*v+1, mid+1, tr, index)
			if curr_time < prev_time:
				return (curr_x, curr_time)
			else:
				return (prev_x, prev_time)

def main():
	# n = number of knights
	# m = number of fights
	n, m = rli()
	ans = [0 for _ in range(n)]
	ST = SegTree(n)
	for time in range(m):
		l, r, x = rli()
		l -= 1
		r -= 1
		x -= 1
		ST.update_range(l, x-1, (x, time))
		ST.update_range(x+1, r, (x, time))

	for i in range(n):
		k, _ = ST.qry(i)
		ans[i] = k + 1 if k < INF else 0
	print(" ".join(str(x) for x in ans))
	stdout.close()

def __starting_point():
	main()
__starting_point()

# Fast IO (only use in integer input)

import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

n,m = list(map(int,input().split()))
conquerer = ['0'] * n
nextKnight = []
for i in range(n):
    nextKnight.append(i)

for _ in range(m):
    l,r,x = list(map(int,input().split()))
    pathList = []
    index = l - 1
    maxIndex = r
    while index < r:
        while index < n and nextKnight[index] != index:
            pathList.append(index)
            index = nextKnight[index]
        if index < r and index != x - 1:
            conquerer[index] = str(x)
            pathList.append(index)
        if index >= r:
            maxIndex = index
        index += 1
    for elem in pathList:
        if elem < x - 1:
            nextKnight[elem] = x - 1
        else:
            nextKnight[elem] = maxIndex

print(' '.join(conquerer))


import sys

I = lambda: int(input())
readline = lambda: sys.stdin.readline().strip('\n')
RM = readmap  = lambda x=int: list(map(x,readline().split(' ')))

n,m = RM()
conq = ['0']*(n+1)
nxt = list(range(1,n+2))#contains the nxt person alive for each person
for _ in range(m):
    l,r,m = RM()
    cur = l
    while cur<=r:
        if conq[cur]=='0' and cur!=m:   conq[cur]=str(m)
        nx = nxt[cur]
        nxt[cur] = [r+1,m][cur<m]#right most of the segment or the conqueror
        cur = nx

print(' '.join(conq[1:]))


import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
##########################################################
from collections import Counter
import math
#n,m=map(int,input().split())
from collections import Counter
#for i in range(n):
import math
#for _ in range(int(input())):
#n = int(input())
#for _ in range(int(input())):
#n = int(input())
import bisect
'''for _ in range(int(input())):

    n=int(input())

    n,k=map(int, input().split())

    arr = list(map(int, input().split()))'''

#n = int(input())
m=0
n,k=list(map(int, input().split()))
ans=[0]*n
jump=[i+1 for i in range(n+2)]
for _ in range(k):
    l,r,x= list(map(int, input().split()))
    i=l
    while i<=r:
        if ans[i-1]==0 and i!=x:
            ans[i-1]=x
        var=jump[i]
        if i<x:
            jump[i]=x
        else:
            jump[i]=r+1
        i=var
    #print(ans)

print(*ans)