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

for i in range(M):
    s, c = map(int, input().split())
    S[s-1] = min(S[s-1], c)

if (S[0] == 0 or S[0] == 10) and N == 1:
    ans = 0
elif S[0] == 0:
    ans = -1
else:
    ans = 0
    for i in range(N):
        if S[i] == 10:
            if i == 0:
                S[i] = 1
            else:
                S[i] = 0
        ans = ans*10 + S[i]

print(ans)