n, m = gets.split(" ").map(&:to_i)

x = Array.new(n, 0)
zero = nil
m.times do
  i, j = gets.split(" ").map(&:to_i)
  x[i-1] = (x[i-1] < j && x[i-1] == 0) || x[i-1] == j ? j : -1;
  if i == 1
    if j == 0 && n != 1
      zero = true
    else
      zero = false
    end
  end
end

if x.find{|a| a == -1}
  print "-1\n"
elsif zero
  print "-1\n"
else
  if zero.nil?
    x[0] = 1
  end
  print "#{x.map(&:to_s).join("").to_i}\n"
end