N,M = list(map(int,input().split()))
S = list("*"*N)
for i in range(M):
    s,c = list(map(int,input().split()))
    if S[s-1] == '*':
        S[s-1]=str(c)
        if S[0]=='0':
            print(-1)
            exit()
    
    elif S[s-1]!=str(c):
        print(-1)
        exit()
if S[0]=='*':
    S[0]='1'
for i in range(N):
    if S[i] == '*':
        S[i] = '0'
print("".join(S))
    
