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

condition = Array.new(n, nil)

dup = false
m.times do
    s, c = gets.split.map(&:to_i)
    if [nil, c].include?(condition[s-1])
        condition[s-1] = c
    else
        dup = true
    end
end

if dup
  puts '-1' 
  return
end

if condition[0].zero? && n > 1
  puts '-1' 
  return
elsif condition[0].zero? && n == 0
  puts '0' 
  return
end

number = condition.map.with_index do |num, index|
    if num.nil? && index.zero?
        1
    elsif num.nil?
        0
    else
        num
    end
end

puts number.join
