from sys import exit

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

ans_l = ["0"] * N
ans_l[0] = "1"
done = [False] * N

for _ in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0:
        print(-1)
        exit()
    if done[s-1]:
        if ans_l[s-1] == str(c):
            continue
        print(-1)
        exit()
    else:
        ans_l[s-1] = str(c)
        done[s-1] = True

print("".join(ans_l))
