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

ans = [-1]*N

for i in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0:
        print(-1)
        exit()
    if ans[s-1] not in (-1, c):
        print(-1)
        exit()
    ans[s-1] = c

if ans[0] == -1:
    if N == 1:
        ans[0] = 0
    else:
        ans[0] = 1

for i in range(N):
    if ans[i] == -1:
        ans[i] = 0

print(*ans, sep='')
