import sys

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

if M == 0:
    print(0)
    sys.exit()
elif N == 1:
    start = 0
    end = 10
else:
    start = 10 ** (N - 1)
    end = 10 ** N

for i in range(start, end):
    ans = list(map(int, str(i)))
    valid = True
    for s, c in SC:
        if ans[s-1] != c:
            valid = False
            break
    if valid:
        print(i)
        sys.exit()

print(-1)
