import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, M = map(int, readline().split())
sc = [tuple(map(int, readline().split())) for _ in range(M)]
sc = sorted(list(set(sc)))

ans = ["*"] * N
for s, c in sc:
    if ans[s - 1] != "*":
        print("-1")
        sys.exit()
    elif (s == 1) & (c == 0):
        print("-1")
        sys.exit()
    else:
        ans[s - 1] = str(c)

for i, c in enumerate(ans):
    if c == "*":
        ans[i] = "0"

if ans[0] == "0":
    ans[0] = "1"
print("".join(ans))
