N, M = map(int, input().split())
ans = [-1]*N
for i in range(M):
    s,m =map(int, input().split())
    if ans[s-1]!=m and ans[s-1]!=-1:
        print(-1)
        exit()
    ans[s-1]=m
if ans[0]==0:
    print(-1)
    exit()
if ans[0]==-1 and ans[1]==0:
    ans[0]=1
for i in range(N):
    if ans[i]==-1:
        ans[i]=0
Ans = [str(a) for a in ans]
print(''.join(Ans))