n,m=map(int,input().split())
d={i:-1 for i in range(1,n+1)}
flg=True
for _ in range(m):
    s,c=map(int,input().split())
    if s==1 and c==0:
        flg=False
    elif d[s]==-1:
        d[s]=c
    else:
        flg=False

ans=[]
for i in range(1,n+1):
    if d[i]==-1:
        if i==1:
            d[i]=1
        else:
            d[i]=0
    ans.append(d[i])
    
if flg:
    print(*ans,sep='')
else:
    print(-1)