N, M = map(int, input().split())

l = ["a"] * N

for i in range(M):
    s, c = map(int, input().split())
    if l[s-1] == "a" or l[s-1] == c:
        l[s-1] = c
    else:
        print(-1)
        exit()

if l[0] == "a":
    l[0] = 1
elif l[0] == 0 and N != 1:
    print(-1)
    exit()

for i in range(N):
    if l[i-1] == "a":
        l[i-1] = 0

l = [str(i) for i in l]
print("".join(l))