N, M = map(int,input().split())

if M == 0:
    if N == 1:
        print("0")
        exit(0)
    elif N == 2:
        print("10")
        exit(0)
    else:
        print(100)
        exit(0)

A = [0 for k in range(N)]
U = [0 for k in range(N)]
for k in range(M):
    s, c = map(int,input().split())
    if U[s-1] == 1 and A[s-1] != c:
        print(-1)
        exit(0)
    else:
        U[s-1] = 1
        A[s-1] = c

if U[0] == 1 and A[0] == 0:
    if N == 1:
        print(0)
    else:
        print(-1)
else:
    for k in range(N):
        if A[k] == 0 and U[k] == 0:
            A[k] = 1
        else:
            break
    print("".join(map(str,A)))
