N,M=map(int,input().split())
A=[0 for i in range(N)]
flg=0

for i in range(M):
    s,c=map(int,input().split())
    if A[s-1]!=0 and A[s-1]!=c:
        flg=1
    if s==1 and c==0:
        flg=1
    if flg==0:
        A[s-1]=c

if flg==1:
    print(-1)
else:
    if A[0]==0:
        A[0]=1
    print(''.join(map(str,A)))