n,m=map(int,input().split())
ls=[list(map(int,input().split())) for i in range(m)]
ans=[-1]*n

flag=True
for i in ls:
    idx,value=i[0]-1,i[1]
    tgt=ans[idx]
    if tgt!=value and tgt!=-1:
        flag=False
        break
    else:
        ans[idx]=i[1]

if flag:
    if ans[0]==0:
        print(-1)
    else:
        for i in range(n):
            if ans[i]==-1:
                if i == 0:
                    ans[i]=1
                else:
                    ans[i]=0
        print(int("".join(list(map(str,ans)))))
else:
    print(-1)