def main():
  N,M=map(int, input().split())

  d={}
  for i in range(M):
    s,c=map(int, input().split())
    if s in d:
      if d[s]!=c:
        print('-1')
        return
    else:
      if s==1 and c==0:
        print('-1')
        return
      d[s]=c
  
  ans=[]
  
  for i in range(N):
    if i+1 in d:
      ans.append(str(d[i+1]))
    else:
      if i==0:
        ans.append(str(1))
      else:
        ans.append(str(0))
  print(''.join(ans))
  return
main()