N,M=map(int,input().split())
s=[list(map(int,input().split())) for i in range(M)]

A=['inf']*N
#print(A)
def main():
    if N==1 and M==0:
        return 0
    if N==2 and M==0:
        return 10
    if N==3 and M==0:
        return 100

    for i in range(M):
        if A[s[i][0]-1]=='inf':
            A[s[i][0]-1]=s[i][1]
        else:
            if A[s[i][0]-1]==s[i][1]:
                continue
            else:
                return -1
                break
    cnt=0
    for j in range(N):
        A[j]=str(A[j])
        if A[j]!='inf':
            cnt+=1
        else:
            if A[j]=='inf':
                if cnt!=0:
                    A[j]='0'
                else:
                    A[j]='1'
    
    if len(str(int(''.join(A))))==N:
        return ''.join(A)
    else:
        return -1
    
print(main())
            
