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 N!=1 and ans[0]==0:
    print(-1)
else:
    l=[str(a) for a in ans]
    print("".join(l))
    