vs = input().split(' ')
N = int(vs[0])
M = int(vs[1])
valueMap = [0 for i in range(N)]

for i in range(M):
  vs = input().split(' ')
  t_i = int(vs[0]) - 1
  t_v = int(vs[1])
  
  if (valueMap[t_i] == 0 or valueMap[t_i] > t_v):
    valueMap[t_i] = t_v
  
if (valueMap[0] == 0):
  print(-1)
else:
  print("".join(map(str, valueMap)))
