N, M = map(int, input().split())

K = [0, -1, -1, -1]
ans = -1
for i in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0:
        break
    if K[s] >= 0 and not K[s] == c:
        break
    K[s] = c
else:
    if K[1] == -1:
        K[1] = 1
    if K[2] == -1:
        K[2] = 0
    if K[3] == -1:
        K[3] = 0

    ans = ''.join(map(str, K[1:N + 1]))

print(ans)
