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
    for s, c in SC:
        if len(i) != N or i[s - 1] != str(c):
            ok = False
    if ok:
        print(i)
        exit()

print(-1)
