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

b=0
for i in range(p):
    if m[l[i][0]-1]==-1:
        m[l[i][0]-1]=l[i][1]
    else:
        if m[l[i][0]-1]!=l[i][1]:
            b=1
            break

if b==1 or m[0]==0:
    print(-1)
else:
    if p==0 and n==1:
        print(0)
    elif p==0 and n==2:
        print(10)
    elif p==0 and n==3:
        print(100)
    else:
        k=0
        for i in range(n):
            if m[i]>-1:
                print(m[i],end="")
            if m[i]==-1 and i!=0:
                print(0,end="")
            if m[i]==-1 and i==0:
                print(1,end="")