N, M = list(map(int, input().split()))
array = [list(map(int, input().split())) for i in range(M)]
answer = ['*' for i in range(N)]
for s, c in array:
    if s == 1 and c == 0:
        print(-1)
        exit()
    if answer[s-1] == '*' or answer[s-1] == c:
        answer[s-1] = c
    else:
        print(-1)
        exit()
if answer[0] == '*':
    answer[0] = 1
for i in range(1, N):
    if answer[i] == '*':
        answer[i] = 0

print(''.join(answer))
