N, M = map(int, input().split())
ans = ["#" for _ in range(N)]
for i in range(M):
    s, c = map(int, input().split())
    if ans[s - 1] == "#" or ans[s - 1] == c:
        ans[s - 1] = c
    else:
        print(-1)
        exit()
for i in range(N):
    if ans[i] == "#":
        if i == 0:
            ans[i] = "1"
        else:
            ans[i] = "0"
if N != 1 and (ans[0] == 0 or ans[0] == "0"):
    print(-1)
else:
    print("".join(map(str, ans)))
