n,m = map(int,input().split())
sc = [tuple(map(int,input().split())) for i in range(m)]
l = [0]*n

for t in sc:
    l[t[0]-1] = t[1]
if len(l)>=2 and all([i==0 for i in l]) and not any([(t[0]==1 and t[1]==0) for t in sc]):
    l[0]=1
    print("".join([str(i) for i in l]))
elif n>=2 and l[0]==0:
    print(-1)
else:
    print("".join([str(i) for i in l]))