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

for i in range(1000):
    j = str(i)
    
    if len(j)!=N:
        continue
    
    for s, c in sc:
        s -= 1
        
        if j[s]!=str(c):
            break
    else:
        print(j)
        exit()

print(-1)