N,M=map(int,input().split())
A=[0]*N
for _ in range(M):
    s,c=map(int,input().split())
    A[s-1]=c

if A.index(0)==0:
    answer=-1
else:
    answer=int(''.join([str(a) for a in A]))

print(answer)