n, m = [int(i) for i in input().split()]
sc = []
for i in range(m):
    sc.append([int(j) for j in input().split()])

c = list("0"*n)
c[0] = "1"
for i, j in sc:
    c[i-1] = str(j)

flag = True
for i, j in sc:
    if c[i-1] != str(j):
        print("-1")
        break
else:
    print("".join(c))