N,M=map(int, input().split())
R=[tuple(map(int, input().split())) for _ in range(M)]
for i in range(10**(N-1), 10**N):
    T = str(i)
    flag = True
    for s,c in R:
        if int(T[s-1]) != c:
            flag = False
            break
    if flag:
        print(i)
        exit()
print(-1)