N, M = map(int,input().split())
list1 = [tuple(map(int,input().split())) for _ in range(M)]
list2 = [0 for _ in range(N)]
for nums in list1:
  s, c= nums[0]-1, nums[1]
  if list2[s] > c or list2[s] == 0:
    list2[s] = c
for s in list2:
  print("{}".format(s),end='')
  