N,M = map(int,input().split())
SC = [[int(i) for i in input().split()] for m in range(M)]
keta = [-1]*N
for s,c in SC:
    if (s,c) == (1,0):
        print(-1)
        exit()
    if keta[s-1] == -1:
        keta[s-1] = c
    elif keta[s-1] == c:
        pass
    else:
        print(-1)
        exit()

for n,k in enumerate(keta):
    if k==-1:
        if n==0:
            keta[n] = 1
        else:
            keta[n] = 0
print("".join([str(k) for k in keta]))