n,m=map(int,input().split())
a=[-1]*n

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