def main():
    flag=False
    N,M=map(int,input().split())
    L=[None]*N
    for i in range(M):
        s,c=map(int,input().split())
        if L[s-1]!=None and L[s-1]!=c:
            flag=True
        L[s-1]=c
        
    if flag:
        return -1

    if L[0]==None:
        L[0]=1
        
    for j in range(len(L)):
        if L[j]==None:
            L[j]=0
    
    output=int(''.join(map(str,L)))
    if N==1:
        return output
    if output and len(str(output))==N:
        return output
    else:
        return -1
    
print(main())

