n,m=map(int,input().split())
l=[tuple(map(int,input().split())) for i in range(m)]
l=set(l)
#[s,c]
ans=['1']+['0']*(n-1)
for s,c in l:
    #1桁の数の時は例外
    if s==1 and c==0 and n>1:
        print(-1)
        exit()
    #既に変更済みの場合
    if s==1 and ans[0]!='1':
        print(-1)
        exit()
    if s!=1 and ans[s-1]!='0':
        print(-1)
        exit()

    ans[s-1]=str(c)
print(*ans,sep='')