n,m=map(int,input().split())
ans=[0]*n
for i in range(m):
    s,c=map(int,input().split())
    ans[s-1]=c
    if c!=0 and ans[s-1]==0:
        ans[s-1]=c 
        pans="0"
    else:
        pans="-1"
                
ans = [str(i) for i in ans]
if pans != "-1":
    pans="".join(ans)
    if pans[0]=="0":
        pans='1' + pans[1:]
print(pans)