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]==0 or c:
    a[s-1]=c
  else:
    print("-1")
    exit()
    
if a[0]==0 and n!=1:
      print("-1")
      exit()
      
for i in range(len(a)):
  print(a[i],end='')