n, m = list(map(int, input().split()))
ss = []
cs = []
for i in range(m):
    s, c = list(map(int, input().split()))
    ss.append(s)
    cs.append(str(c))

ans = ["_"] * n

for s, c in zip(ss, cs):
    # print(f"ans={ans}: s={s}, c={c}")
    if ans[s-1] == "_" or ans[s-1] == c:
        ans[s-1] = c
    else:
        print("-1")
        exit()

if m == 0:
    print("100")
    exit()

if n == 1 and ans[0] == "0":
    print("0")
    exit()

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

if ans[0] == "_":
    ans[0] = "1"

print("".join(ans).replace("_", "0"))
