n,m=map(int,input().split())
a=[0]*n
count=0
for i in range(m):
  s,c=map(int,input().split())
  if a[s-1]==[] or c:
    a[s-1]=c
  else:
    print("-1")
    exit()
    
if a[0]==0:
  for i in range(m-1):
    if a[i]==0:
      count+=1
    if count==m-1:
      print("-1")
      exit()
for i in range(len(a)):
  print(a[i],end='')