N, M = map(int, input().split())
S = []
C = []
for i in range(M):
    s, c = input().split()
    S.append(int(s))
    C.append(int(c))

A = [0]*N
for a, b in zip(S, C):
    A[a-1] = b

if len(A) != 1 and A[0] == 0:
    print(-1)
else:
    for a in A:
        print(a, end="")
