N, M = map(int, input().split())
sc = []
for i in range(M):
    sc.append(list(map(int, input().split())))
    
for i in range(10**(N-1), 1000):
    i = str(i)
    flag = True
    for j in range(M):
        if int(i[sc[j][0]-1]) != sc[j][1]:
            flag = False
    if flag:
        print(int(i))
        exit()
        
print(-1)