N,M = map(int,input().split())
ans = [0]*N
for i in range(M):
    s,c = map(int,input().split())
    ans[s-1] = c
if ans[0] == 0:
    if len(ans) != 1:
        print(-1)
        exit()
print("".join([str(i) for i in ans]))
