N, M = map(int, input().split())
answer = [0 for _ in range(N)]

for _ in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0:
        print(-1)
        exit()

    if answer[s-1] == 0:
        answer[s-1] = c
    else:
        if not answer[s-1] == c:
            print(-1)
            exit()

if answer[0] == 0:
    answer[0] = 1

print("".join(list(map(str, answer))))
