n, m = map(int,input().split())
cond = []
ans = [False] * n
for _ in range(m):
    cond.append(list(map(int,input().split())))
    if cond[-1][0] == 1 and cond[-1][1] == 0 and n != 1:
        print(-1)
        exit()
    if not ans[cond[-1][0]-1]:
        ans[cond[-1][0]-1] = cond[-1][1]
    elif ans[cond[-1][0]-1] == cond[-1][1]:
        continue
    else:
        print(-1)
        exit()

for i in range(len(ans)):
    if not ans[i]:
        if i == 0:
            ans[i] = 1
        else:
            ans[i] = 0
print(*ans,sep="")