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

condition = set()
for i in range(M):
    s, c = map(int, input().split())
    condition.add((s, c))

ans = float("inf")
for i in range(10**(N-1), 10**N):
    num = str(i)
    for s, c in condition:
        if num[s-1] != str(c):
            break
    else:
        print(i)
        exit()
print(-1)