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