n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]

ans = ["x"] * n

for s, c in sc:
    if ans[s - 1] == "x":
        ans[s - 1] = str(c)
    else:
        if ans[s - 1] != str(c):
            print(-1)
            exit()

for i in range(len(ans)):
    if ans[i] == "x":
        if i != 0:
            ans[i] = "0"
        else:
            ans[i] = "1"

if len(ans) > 1 and ans[0] == "0":
    print(-1)
    exit()

print("".join(ans))