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

for i in range(10**(N-1), 10**N):
    n = str(i)
    
    for s, c in sc:
        if n[s-1] != str(c): break
    else:
        print(n)
        break
    
else: print(-1)