N, M = map(int, input().split())
SCm = [list(map(int, input().split())) for _ in range(M)]

ans = ["-1"] * N
res = True
for i in range(M):
    s, c = SCm[i]
    if ans[s - 1] == "-1" or ans[s - 1] == str(c):
        ans[s - 1] = str(c)
    else:
        res = False
        break

if ans[0] == "0":
    res = False
else:
    for i in range(N):
        if ans[i] == "-1":
            if i == 0:
                ans[i] = "1"
            else:
                ans[i] = "0"

print("".join(ans) if res else "-1")
