n,m=map(int,input().split())

ans=["#"]*n
for _ in range(m):
    s,c=map(int,input().split())
    if not ans[s-1] in["#",c]:
        print(-1)
        exit()
    ans[s-1]=c
    

if ans[0]=="#":
    ans[0]=1
if ans[0]==0:
    print(-1)
    exit()

for num in ans:
    print(num if num!="#" else 0,end="")
