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

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

print(-1)