n, m = gets.split.map &:to_i
digits = n.times.map {-1}
m.times do
  s, c = gets.split.map &:to_i
  if digits[s-1] != -1 and digits[s-1] != c
    puts "-1"
    exit
  end
  if c == 0 and s == 1
    puts "-1"
    exit
  end
  digits[s-1] = c
end

default = "1"
puts digits.map { |c|
  if c == -1
    default
  else
    default = "0"
    c.to_s
  end
}.join("")