n,m=map(int,input().split())
L=[-1]*n
for i in range(m):
  a,b=map(int,input().split())
  if L[a-1]!=-1:
    if L[a-1]!=b:
      print(-1)
      exit()
  else:
    L[a-1]=b
  if a==1 and b==0:
    print(-1)
    exit()
for i in range(len(L)):
  if L[i]==-1:
    L[i]=0
L=list(map(int,L))
print("".join(L))