n,m=map(int,input().split())
ans=[-1]*n
for _ in range(m):
    s,c=map(int,input().split())
    if ans[s-1]==-1:
        ans[s-1]=c
    elif ans[s-1]!=c:
        print(-1)
        exit()
if ans[0]==0:
    if n==1:
        print(0)
    else:
        print(-1)
        exit()
elif ans[0]==-1:
    if n==1:
        ans[0]=0
    else:
        ans[0]=1
for i in range(1,n):
    if ans[i]==-1:
        ans[i]=0
ans_=""
for i in range(n):
    ans_+=str(ans[i])
print(ans_)