n, m = gets.split.map(&:to_i)
digits = Array.new(n, 0)
digits[0] = 1
decided = Array.new(n, false)
ok = true
m.times do
  s, c = gets.split.map(&:to_i)
  if !decided[s-1]
    if n > 1 && s == 1 && c == 0
      ok = false
    else
      digits[s-1] = c
      decided[s-1] = true
    end
  else
    ok = false if digits[s-1] != c
  end
end
puts (ok) ? digits.join : -1
