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