n,m=map(int,input().split())
ans=[-1]*n
for i in range(m):
    s,c=map(int,input().split())
    if ans[s-1]==-1 or (ans[s-1]!=-1 and ans[s-1]==c):
        if s-1==0 and c==0:
            print(-1)
            break
        else:
            ans[s-1]=c
    else:
        print(-1)
        break
else:
    for i in range(m):
        if ans[0]==-1:
            ans[0]=1
        elif ans[i]==-1:
            ans[i]=0
    print(*ans,sep="")