n, m = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(m)]
N = [None] * n
for s, c in L:
    if N[s - 1] is None:
        N[s - 1] = c
    elif N[s - 1] == c:
        continue
    else:
        print(-1)
        exit()

if n == 1:
    print(*N)
    exit()
elif N[0] == 0:
    print(-1)
    exit()

for i in range(n):
    if i == 0 and N[0] is None:
        N[0] = 1
    elif N[i] is None:
        N[i] = 0
print(*N, sep='')
