n,m=map(int,input().split())
ans=[0]*n

for _ in range(m):
  s,c=map(int,input().split())
  ans[s-1]=c
if n>1 and ans[0]==0:
  print(-1)
  exit()
elif n==1 ans[0]==0:
  print(0)
  exit()
else:
  for i in ans:
    print(i,end="")
