io = STDIN
n,m=io.gets.split.map(&:to_i)
ar=m.times.map{io.gets.split.map(&:to_i)}
def check(ar,n)
  str=" "*n
  ar.each do |s,c|
    if n==1 && s==1 && str[0] == " " && c==0
    elsif s==1 && c==0
      return "-1"
    elsif str[s-1] == " " ||
      str[s-1]==c.to_s
      str[s-1]=c.to_s
    else
      return "-1"
    end
  end
  if str[0]==" "
    str[0]="1"
  end
  str.gsub(" ","0")
end
puts check(ar,n)
