n,m = map(int,input().split())
d = {}
for _ in range(m):
    s,c = map(int,input().split())
    if s == 1 and c == 0:
        print ("-1")
        exit ()
    if s in d.keys():
        if d[s] != c:
            print ("-1")
            exit ()
    else:
        d[s] = c
#    print (d)
for i in range(1,n+1):
    if i in d.keys():
        print (d[i],end="")
    else:
        if i == 1:
            print (1,end="")
        else:
            print (0,end="")

print ()