n,m=map(int,input().split())
ans = [11]*n
for i in range(m):
  s,c=map(int,input().split())
  if ans[s-1] > c:
    ans[s-1]=c

if ans[0]==11 and n>=2:
  print(-1)
else:
  for i in range (len(ans)):
    if ans[i]==11:
      ans[i] = 0
  for i in ans:
    print(i,end='')