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

str = "x" * n
str[0] = "y"

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

nums = []

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

puts str
