import sys

n, m = map(int, input().split())
N = [None]*n
for _ in range(m):
    s, c = map(int, input().split())
    if s-1 == c == 0:
        print(-1)
        sys.exit(0)
    if N[s-1] == None or N[s-1] == c:
        N[s-1] = c
    else:
        print(-1)
        sys.exit(0)
if N[0] == None and n > 1:
    N[0] = 1
for i in range(n):
    if N[i] == None:
        N[i] = 0
    print(N[i], end="")
print()