n, m = gets.split.map{|e| e.to_i}

str = "x" * n

m.times do
  s, c = gets.split.map{|e| e.to_i}
  if str[s-1] == "x" or str[s-1] == "#{c}"
    str[s-1] = "#{c}"
  else
    puts "-1"
    exit
  end
end

str.gsub!("x","0")

if str[0] == "0" and str.length == 1
    puts "0"
    exit
end

if str[0] == "0"
    puts "-1"
    exit
end

if str[0] == "0" and str[1] == "0"
    puts "-1"
    exit
end

puts str
