n,k=list(map(int, input().split()))
x=["1"]+["0" for i in range(n-1)]
visited={}
falg=0
for i in range(k):
  a,b=list(map(int, input().split()))
  if a not in visited:
    visited[a]=b
    x[a-1]=str(b)
  else:
    if visited[a]!=b:
      falg=1
      print(-1)
      break
  if x[0]=="0" and n!=1:
      print(-1)
      break
else:
  s=""
  for i in x:
    s+=i
  print(s)
  