N,M = map(int, input().split())
A = [10]*N
for i in range(M):
    s,c = map(int, input().split())
    if A[s-1] == 10 or A[s-1] == c:
        A[s-1] = c
    else:
        print(-1)
        break
else:
    if A[0]==10:
        A[0]=1
        
    if A[0]==0:
        print(-1)
    else:
        for j in range(1,N):
            if A[j] ==10:
                A[j] = 0
        A = map(str,A)
        print(''.join(A))