import sys
n,m=list(map(int,input().split()))
ans=[-1 for i in range(n)]
num=0
for i in range(m):
  
  s,c=list(map(int,input().split()))
  if s==1 and c==0:
    print(-1)
    sys.exit()
  else:
    if ans[s-1]==-1 or ans[s-1]==c:
      ans[s-1]=c
    else:
      print(-1)
      sys.exit()

if ans[0]==0:
  ans[0]=1
for i in range(1,n):
  if ans[i]==-1:
    ans[i]=0
ans=map(str, ans)
print("".join(ans))

  