N,M = map(int,input().split())
SC = [tuple(map(int,input().split())) for i in range(M)]

for n in range(10**(N-1),10**N):
    n = str(n)
    for s,c in SC:
        if n[s-1] != str(c):
            break
    else:
        print(n)
        exit()
print(-1)