import sys
n, m = [int(i) for i in sys.stdin.readline().split()]
ls = []
ans = ["x"] * (n)
for i in range(m):
    s, c = [int(i) for i in sys.stdin.readline().split()]
    s -= 1
    if ans[s] != "x" and ans[s] != str(c):
        ans = -1
        break
    else:
        ans[s] = str(c)
if ans == -1 or ans[0] == "0":
    print(-1)
else:
    if ans[0] == "x":
        ans[0] = "1"
    ans = "".join(ans)
    ans = ans.replace("x", "0")
    print(ans)