n, m = map(int, input().split())
S = ["0" 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] != "0") or (s == 1 and c == 0):
        r = False
        pass
    else:
        S[s - 1] = str(c)
if S[0] == "0":
    S[0] = "1"
print("".join(S)) if r else print(-1)
