n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
ans=[1]+[0]*(n-1)
for s,t in l:
    if s==1 and t==0:
        print(-1)
        quit()
    if s>n:
        print(-1)
        quit()
    ans[s-1]=t
for s,t in l:
    if ans[s-1]!=t:
        print(-1)
        quit()
print("".join(map(str,ans)))