def main():
  n,m=map(int,input().split())
  ans=[0]*n
  ans[0]=1
  flag=[0]*n
  for _ in range(m):
    s,c=map(int,input().split())
    if s==1 and c==0:
      print(-1)
      exit()
    if flag[s-1]==0:
      ans[s-1]=c
      flag[s-1]=1
    else:
      if ans[s-1]!=c:
        print(-1)
        exit()
  print(''.join([str(i) for i in ans]))        
if __name__=='__main__':
  main()