n,m=map(int,input().split())
num=0
array=[99999 for i in range(n)]
for _ in range(m):
  s,c = map(int,input().split())
  if array[s-1]==99999 or array[s-1]==c:
    array[s-1]=c
  else:
    array=[-1 for i in range(n)]
    break

if not n==1:
  for i in range(n):
    if not i==1:
      if array[i]==99999:
        array[i]=0
    else:
      array[i]=1
  if array[0]==0 or array[0]==-1:
    num=-1
  else:
    num=int(''.join(list(map(str,array))))
else:
  if array[0]==99999:
    num=-1
  else:
    num=array[0]
print(num)
    
    
