n,m=map(int,input().split())
d=["a"]*n
ans=""
if m==0:
    ans="-1"
    print(-1)
else:
    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"
            print(ans)
            break
if d[0]!="0" and ans!="-1":
    if d[0]=="a" or d[0]=="0":
        print("u","".join(["1"]+d[1:]).replace("a","0"))
    else:
        print(("".join(d)).replace("a","0"))
elif d[0]=="0" and ans!="-1":
    print(-1)