n,m=map(int,input().split())
data=[0]*n
for i in range(m):
  s,c=map(int,input().split())
  if data[s-1]==0 or data[s-1]==c:
    data[s-1]=c
  else:
    print(-1)
    exit()
  if s==1 and c==0:
    print(-1)
    exit()
if data[0]==0:
  data[0]=1
print(*data,sep='')