n, m = map(int, input().split())
ans = [1] + [0] * (n-1) if n != 1 else [0]
flag = [False] * n
for _ in range(m):
    s, c = map(int, input().split())
    s -= 1
    if s == 0 and c == 0: print(-1); break
    if flag[s] and ans[s] != c: print(-1); break
    ans[s] = c
    flag[s] = True
else: print(*ans, sep="")
