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

start = 10**(N-1)
end = 10**N

for n in range(start,end):
    n = str(n)
    b = True
    for s,c in SC:
        if n[s-1] != str(c):
            b = False
            break
    if b:
        print(n)
        break
if not b:
    print(-1)
