n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

if m == 0:
    if n == 1:
        print(0)
    else:
        print(10 ** (n - 1))
    exit()

ans = -1
for i in range(10 ** n):
    i = str(i)
    for s, c in sc:
        if int(i[s - 1]) != c:
            break
    else:
        ans = i
        break

print(ans)
