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