n,m=map(int,input().split())
if m==0:
    print(10**(n-1))
    exit()
d={}
for _ in range(m):
    s,c=map(int,input().split())
    s-=1
    if s==0 and c==0:
        if n==1:
            print(0)
            exit()
        print(-1)
        exit()
    if s in d and d[s]!=c:
        print(-1)
        exit()
    else:
        d[s]=c
l=["0"]*n
for i,k in d.items():
    l[i]=str(k)
if l[0]=="0":
    l[0]="1"
print("".join(l))
