n,m = map(int,input().split())
sc = [tuple(map(int,input().split())) for i in range(m)]
l = [0]*n
if m==0 or (all([sc[0][0]!=1 for t in sc])):
    l[0] = 1
    print("".join([str(i) for i in l]))
else:
    for t in sc:
        l[t[0]-1] = t[1]
    if l[0] == 0:
        print(-1)
    else:
        print("".join([str(i) for i in l]))