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

a = [0]*N

for i in range(0,3):
    for s,c in SC:
        if i+1 == s:
            a[i] = c

ans = ""
for i in a:
    ans = ans + str(i)

ans = int(ans)
for i in range(10**N+1):
    if len(str(ans)) != N:
        break
    if i == ans:
        print(i)
        exit()

print(-1)