def main():
  N,M = map(int, input().split())
  num = [-1]*N
  for i in range(M):
    s,c = map(int,input().split())
    if (num[s-1]>=0 and num[s-1]!=c) or (s==1 and c==0):
      print(-1)
      return
    else: num[s-1] = c
  
  if num[0]==0: print(-1)
  else:
    num[0] = 1 if num[0]<0 else num[0]
    print("".join([str(i if i>0 else 0) for i in num]))
  
main()