N, M = map(int, input().split())
sc_list = [list(map(int, input().split())) for i in range(M)]
POSSIBLE = False
for n in range(10**N):
    n_str = str(n)
    for j in range(len(sc_list)):
        if sc_list[j][0] > len(n_str):
            break
        if n_str[sc_list[j][0]-1] != str(sc_list[j][1]):
            break
    else:
        POSSIBLE = True
        break
print(n_str if POSSIBLE else '-1')