N,M=map(int,input().split())
l=[-1]*N
a=[]
for i in range(M):
    s,c=map(int,input().split())
    if l[s-1]!=c and l[s-1]!=-1:
        a=-1
        break
    l[s-1]=c
else:
    for i in range(N):
        if l[i]==-1 and i:
            a.append(0)
        elif l[i]==-1:
            a.append(1)
        else:
            a.append(l[i])
if a==-1:
    print(a)
elif a[0]==0:
    print(-1)
else:
    print(*a,sep="")     