N,M=map(int,input().split())
ans=10**(N-1)
if M==0:
    print(ans)
else:
    S=[]
    C=[]
    for i in range(M):
        s,c=map(int,input().split())
        S.append(s)
        C.append(c)
    for i in range(1000):
        flag=True
        I=str(i)
        for j in range(M):
            if len(I)<S[j]:
                flag=False
            else:
                if I[S[j]-1]!=str(C[j]):
                    flag=False
        if flag==True:
            print(i)
            exit()
    print(-1)