f=lambda:map(int,input().split())
n,m=f()
l,b=[0]*n,[0]*n
if n>1: l[0]=1
for _ in range(m):
  s,c=f(); s-=1
  if b[s] and l[s]!=c or n>1 and s==c==0: print(-1); exit()
  l[s],b[s]=c,1
print(*l,sep='')