n,m=list(map(int,input().split()))

dig=[-1]*(n+1)

rets='1'+''.join(['0' for i in range(n-1)])


for i in range(m):
    s,c=list(map(int,input().split()))

    if (dig[s]>-1 and dig[s]!=c) or (s==1 and c==0):
        print('-1')
        exit(0)
    
    dig[s]=c
    rets=rets[:s-1]+str(c)+rets[s:]

print(rets)