N,M = map(int,input().split())
S = [0]*M
C = [0]*M
for i in range(M):
    S[i],C[i] = map(int,input().split())
answer = -1

for i in range(10**(N-1),10**N):
    numstr = str(i)
    count = 0
    for j in range(M):
        if int(numstr[S[j]-1]) != C[j]:
            break
        else:
            count += 1
    if count == N:
        answer = i
        break
    else:
        answer = -1
        
print(answer)