N, M = map(int, input().split())
sc = []
for _ in range(M):
    s, c = map(int, input().split())
    sc.append((s - 1, str(c)))

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