n,m=map(int,input().split())
l=[-1]*n

for i in range(m):
  s,c=map(int,input().split())
  if l[s-1]<0:
    l[s-1]=c
  elif l[s-1]!=c:
    print(-1)
if n>1 and l[0]==0:
  print(-1)
elif n>1 and l[0]==-1:
  l[0]=1
elif n=1 and l[0]<0:
  l[0]=0
for j in range(1,n):
  if l[j]<0:
    l[j]=0

ans="".join(map(str,l))
print(int(ans))