n,m=map(int,input().split())
s=["0"]*n
for i in range(m):
    a,b=map(int,input().split())
    if s[a-1]=="0":
        s[a-1]=str(b)
    elif s[a-1]!=str(b):
        print(-1)
        exit()
if s[0]=="0":
    s[0]="1"
print("".join(s))