n, m = map(int, input().split())
S = ["a" for i in range(n)]
r = True
for _ in range(m):
    s, c = map(int, input().split())
    if (S[s - 1] != str(c) and S[s - 1] != "a") or (s == 1 and c == 0 and n != 1):
        r = False
    else:
        S[s - 1] = str(c)
if S[0] == "a":
    S[0] = "1"
for i in range(1, n):
    if S[i] == "a":
        S[i] = "0"
print("".join(S)) if r else print(-1)
