N,M=map(int,input().split())
A=["10"]*N
for i in range(M):
    s,c=input().split()
    s=int(s)
    s-=1
    if (A[s]!="10" and A[s]!=c) or (s==0 and c=="0"):
        print("-1")
        exit()
    A[s]=c
for i in range(N):
    if A[i]=="10":
        if i==0:
            A[i]="1"
        else:
            A[i]="0"
print("".join(A))