N,X=map(int,input().split())
#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S = [[0 for j in range(2)] for i in range(X)]
L=[0]*N
R=[False]*3
for i in range(X):
    s,c=map(int,input().split())
    if N>=2:
        if s==1 and c==0:
            print(-1)
            exit()
    S[i][0]=s
    S[i][1]=c
    
    
    
    if R[s-1]==True and L[s-1]!=c:
        print(-1)
        exit()
    L[s-1]=c
    R[s-1]=True

if N==2 and L==[0,0]:
    print(1)
    exit()
if N==3  and R==[False,True,True]:
    L[0]=1
elif N==3 and R==[False,False,True]:
    L[1]=1
       
elif N==3 and R==[False,True,False]:
    L[0]=1
    
Z=[str(a) for a in L]
Z="".join(Z)
print(Z)
