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

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

for j in range(1,n):
  if l[j]<0:
    l[j]=0

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