N,M = map(int,input().split())
Z = [0] * N
for i in range(M):
    s,c = map(int,input().split())
    Z[s-1] =c 
ans =0
N2 = N
for z in Z:
    ans += 10**(N-1)*z
    N-=1
if len(str(ans))==N2:
    print(ans)
else:
    print(-1)