N, M = map(int, input().split())
SC = [tuple(map(int, input().split())) for _ in range(M)]
for i in range(10 ** N):
    i, ok = str(i), True
    if len(i) == N:
        for s, c in SC:
            if i[s - 1] != str(c):
                ok = False
        if ok:
            print(i)
            exit()

print(-1)
