N,M = [int(x) for x in input().split()]
answer = [0] * N
for _ in range(M):
    p, v = [int(x) for x in input().split()]
    answer[p - 1] = v
if answer[0] == 0 and N > 1:print(-1)
else:print("".join(map(str,answer)))