n,m=gets.split.map(&:to_i)
b=Array.new(n)
m.times do
  s,c=gets.split.map(&:to_i)
  if [s,c]==[1,0]
    puts -1
    exit
  end
  if !b[s-1] || b[s-1]==c
    b[s-1]=c
  else
    puts -1
    exit
  end
end
b[0]=1 unless b[0]
b.each{|s|print s ? s : 0}