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 and n!=1:
    print(-1)
    exit()
for i in range(len(L)):
  if L[i]==-1:
    L[i]=0
L=list(map(str,L))
k="".join(L)
k=int(k)
if k==0 and n!=1:
  print(10**(n-1))
  exit()
else:
  print(k)