n,m=map(int,input().split())
sc=set(tuple(map(int,input().split())) for i in range(m))

S=['1']+['0']*(n-1)
for s,c in sc:
    if s==1 and c==0 and n>1:
        print(-1)
        exit()
    elif n>1 and S[0]!='1':
        print(-1)
        exit()
    elif s>1 and S[s-1]!='0':
        print(-1)
        exit()
    S[s-1]=str(c)
    #print(S)
if n==1 and m==0:S='0'
print(*S,sep='')