N, M = map(int, input().split())
sc = []
for _ in range(M):
    sc.append(list(map(int, input().split())))

for n in range(10**(N - 1), 10**(N + 1) - 1):
    n = str(n)
    for si, ci in sc:
        if int(n[si - 1]) != ci:
            break
    else:
        print(n)
        break
else:
    print(-1)