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