n,m=map(int,input().split())
d=["a"]*n
ans=""
for i in range(m):
    s,c=map(str,input().split())
    s=int(s)
    if d[s-1]=="a" or d[s-1]==c:
        d[s-1]=c #置き換え
    else:
        ans="-1"
        break
if d[0]=="0":
    print(-1)
elif d[0]=="a":
    d[0]="1"
    if d[2]=="a":
        print(-1)
    else:
        print(("".join(d)))
else:
    print(("".join(d)).replace("a","0"))