n,m=list(map(int,input().split()))
ans=[1]+[0]*(n-1)
check=0

for _ in range(m):
    s,c=list(map(int,input().split()))
    s-=1
    if s==0:
        if c==0:
            check+=1
            break
        elif ans[s]!=1:
            check+=1
            break
        else:
            ans[s]=c
    else:
        if ans[s]!=0:
            check+=1
            break
        else:
            ans[s]=c
if check>0:
  print(str(-1))
else:
  ans=list(map(str,ans))
  print("".join(ans))
