def convert(s): 
  
    # initialization of string to "" 
    new = "" 
  
    # traverse in the string  
    for x in s: 
        new += x  
  
    # return string  
    return new 

n,m=map(int,input().split())
a=[]
for i in range(n):
  a.append(0)
b=[]
if n==1:
  b.append(0)
else:
  b.append(1)
  for i in range(n-1):
    b.append(0)
fail=0
for i in range(m):
  s,c=map(int,input().split())
  if c!= b[s-1] and a[s-1]==1:
    fail=1
    break
  b[s-1]=c
  a[s-1]=1
for i in range(n):
  b[i]=str(b[i])
if fail==1:
  print(-1)
else:
  print(convert(b))
    
    
      