N,M = map(int,input().split())
s =[]
c = []

for j in range(M):
    S, C = map(int,input().split())
    s.append(S)
    c.append(C)

answer = -1
for i in range(pow(10,N-1),pow(10,N)):
    istr = str(i)
    
    hantei =1
    for j in range(M):
        if int(istr[s[j]-1]) !=c[j]:
            hantei = -1
            break
    if hantei == -1:
        pass
    else:
        answer = i
        break

print(answer)