N, M = list(map(int, input().split()))
ans = -1
sc = [list(map(int, input().split())) for i in range(M)]

for i in range(10**N):
    x = str(i).zfill(3)

    f = True
    for s, c in sc:
        if x[s-1] != str(c): f = False; break
    if f: ans = i; break

if ans == 0: ans = -1
print(ans)
