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 sc[0][0]!=1 and sc[0][1]==0:
    l[0]=1
    print("".join([str(s) for s in l]))
elif l[0]==0:
    print(-1)
else:
    print("".join([str(s) for s in l]))