keta,num=map(int,input().split())
list=[list(map(int,input().split())) for i in range(num)]

ans = [0]*keta
for i in range(num):
  if ans[list[i][0]-1] < list[i][1]:
    ans[list[i][0]-1] = list[i][1]
if ans.count(0) == keta:
  print(0)
else:
  a = ''
  for s in ans:
    a += str(s)
  print(a)