import sys
n,m=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(m)]
a=int("1" +"0"*(n-1))
d=[-1 for _ in range(n)]
for b in s:
  if d[b[0]-1]== -1:
    d[b[0]-1]=b[1]
  else:
    if d[b[0]-1]!=b[1]:
      print(-1)
      sys.exit()
if d[0]==-1:
  d[0]==1
elif d[0]==0 and n>1:
  print(-1)
  sys.exit()
  
for i in range(n):
  if d[i] ==-1:
    d[i]=0
print("".join(map(str,d)))
    
  