n,m=map(int,input().split())
l=[""]*n
s=0
for k in range(m):
  i,j=map(int,input().split())
  if l[i-1]=="" or l[i-1]==str(j):
    l[i-1]=str(j)
  else:
    s=1
    break
  if i==1 and j==0:
    if n!=1:
      s=1
      break
if s==0:
  for k in range(n):
    if l[k]=="":
      if k==0:
        l[k]="1"
      else:
        l[k]="0"
  a="".join(l)
  print(int(a))
else:
  print(-1)
