N,M=map(int,input().split())
s=[]
c=[]
x=dict()
for i in range(M):
    a,b=map(int,input().split())
    s.append(a)
    c.append(b)
    if a in x:
        if b!=x[a]:
            print(-1)
            exit()
    else:
        x[a]=b
if M==0:
    ans=""
    for i in range(N):
        if i==0:
            ans="1"
        else:
            ans=ans+"0"
    print(ans)
    exit()
l=[]
if N!=1:
    for i in range(N):
        if s[i]==1:
            if c[i]==0:
                print(-1)
                exit()
                

for i in range(N):
    if i==0:
        l.append(1)
    else:
        l.append(0)

for i in range(M):
    l[s[i]-1]=c[i]
ans=""
#print(l)

for i in range(N):
    ans=ans+str(l[i])
print(ans)