import sys

n, m = map(int, input().split())

L = [float("inf") for i in range(n)]

for i in range(m):
    s, c = map(int, input().split())
    if L[s - 1] == c:
        continue
    elif L[s - 1] < float("inf"):
        print(-1)
        sys.exit()
    else:
        L[s - 1] = c

if L[0] == 0:
    print(-1)
elif L[0] == float("inf"):
    L[0] = str(1)
    for i in range(1, n):
        if L[i] == float("inf"):
            L[i] = str(0)
        else:
            L[i] = str(L[i])
    print("".join(L))

else:
    for i in range(n):
        if L[i] == float("inf"):
            L[i] = str(0)
        else:
            L[i] = str(L[i])
    print("".join(L))

