N,M=list(int(i) for i in input().split())
A=[-1 for i in range(N)]
bool=False
for i in range(M):
    s,c=list(int(i) for i in input().split())
    if s>1:
        if A[s-1]==-1:
            A[s-1]=c
        else:
            print(-1)
            bool=True
            break
    if s==1:
        if c>=0:
            A[s-1]=c
if bool is False:
    if A[0]==0:
        print(-1)
    else:
        if A[0]==-1:
            A[0]=1
            for i in range(len(A)):
                if A[i]==-1:
                    A[i]=0
            listToStr = ''.join(map(str, A))
            print(listToStr)
        else:
            for i in range(len(A)):
                if A[i]==-1:
                    A[i]=0
            
            listToStr = ''.join(map(str, A))
            print(listToStr)




