def main():
    n,m=map(int,input().split())
    L=[list(map(int,input().split())) for _ in range(m)]
    if m>1:
        for i in range(m-1):
            for j in range(i+1,m):
                if L[i][0]==L[j][0] and L[i][1]!=L[j][1] :
                    print(-1)
                    return
    for l in L:
        if l[0]==1 and l[1]==0:
            print(-1)
            return
    if n==0:
        ans=[0]
    else:
        ans=list('1'+'0'*(n-1))
    for l in L:
        ans[l[0]-1]=str(l[1])
    print(''.join(ans))
main()