N,M=map(int,input().split())
ans=[None]*N
flg=0

for i in range(M):
    s,c =map(int,input().split())
    if ans[s-1]==None:
        ans[s-1]=str(c)
    elif ans[s-1]==str(c):
        pass
    else:
        flg=1
        

if ans[0]==None:ans[0]=str(1)

for i in range(1,N):
    if ans[i]==None:ans[i]=str(0)
        
num=int("".join(ans))

if len(str(num))!=N or flg==1:
    print(-1)
else:
    print(num)