N, M = map(int, input().split())
ans = [-1] * N
for _ in range(M):
    s, c = map(int, input().split())
    if ans[s - 1] == -1:
        ans[s - 1] = c
        continue
    if ans[s - 1] != c:
        print(-1)
        exit()

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

answer = ""
for i, a in enumerate(ans):
    if a == -1:
        answer += "0" if i != 0 else "1"
    else:
        answer += str(a)

print(answer)
