n,m=map(int,input().split())
ans=[10 for _ in range(n)]
for i in range(m):
    place,num=map(int,input().split())
    if ans[place-1]==10:
        ans[place-1]=num
    elif ans[place-1]!=num:
        ans=-1
        print(ans)
        break
if ans[0]==0:
    ans=-1
    print(ans)
if ans!=-1:
    for j in range(n):
        if j==0 and ans[j]==10:
            ans[j]=1
        if j>0 and ans[j]==10:
            ans[j]=0
    ans=map(str,ans)
    print("".join(ans))